Not sure if localStorage is truly what you want here as it is indeed local. So when you add an item on your PC, you won't be able to see it on your phone, etc.
Thanks for the reply I was attempting something similar but I think I just missed a step. I wasn't sure about LS if not LS then Vuex? Is there an alternative? I'm still pretty much a beginner to lot of this stuff so open to any suggestions.
It really depends on your use case. But if you want to persist data so that, when one user adds a method, every person on the internet should see it too, then vuex won't help here either. It is just a way to manage your local state.
In such a case, what you actually want is to persist the data in a database like MySQL (requires server) or maybe something serverless like Firebase. Firebase is probably easier to set up as you don't need to host the database yourself somewhere and there is a free tier that should be good enough.
Not sure if localStorage is truly what you want here as it is indeed local. So when you add an item on your PC, you won't be able to see it on your phone, etc.
Here's how a simple localStorage implementation could look like in this file: github.com/cguttweb/array-helper/b...
arrayMethods
Inside
data()
retrieve the added items (or default it to an empty array), then add it toarrayMethods
addMethod()
, set the localStorage:Thanks for the reply I was attempting something similar but I think I just missed a step. I wasn't sure about LS if not LS then Vuex? Is there an alternative? I'm still pretty much a beginner to lot of this stuff so open to any suggestions.
It really depends on your use case. But if you want to persist data so that, when one user adds a method, every person on the internet should see it too, then vuex won't help here either. It is just a way to manage your local state.
In such a case, what you actually want is to persist the data in a database like MySQL (requires server) or maybe something serverless like Firebase. Firebase is probably easier to set up as you don't need to host the database yourself somewhere and there is a free tier that should be good enough.
I've read a bit on Firebase I will take a look and give it a go thanks :)