I have a component that is provided an initial data property via a passed-in component prop and stored in a data variable:
<component :propvar="true"></component>
data() {
return {
localvar: this.propvar,
localvar2: true
}
}
I would like to be able to revert the data variable back to this prop's value when hitting a 'reset' button with a method like this:
methods: {
reset() {
Object.assign(this.$data, this.$options.data());
}
}
The problem is that the data variable is undefined when referencing the prop's value via this.options.data():
console.log(this.$options.data()); => Object {localvar: undefined, localvar2: true}