Note this was an edit in my question, but I make it separately answer as @nathanvda suggested.
I found the solution that I was looking for. first use watch method to detect changes on variable you are storing data on like this:
watch: {
input: function () {
if (isLocalStorage() /* function to detect if localstorage is supported*/) {
localStorage.setItem('storedData', this.input)
}
}
}
This will update variable’s value whenever user add new inputs.
Then assign the new value to variable like this:
app.input = localStorage.getItem('storedData');
And that's it :)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…