How can I assign data to a dynamic variable.
What I'm trying to achieve is this:
My vue data variable:
test: '',
Adding a click
<div @click="assignData(test)"
Method:
assignData(value) {
// Now I don't want this
this.test = 'lorem..';
// Instead I want something like this
value = 'new value for test';
// Or
this.value = 'new value for test';
}
Now obviously this is not gonna work, but I hope you'll get the idea.
I need to change many variables and I don't want to add all the variables in the function like this
assignData(value) {
this.test = 'lorem..';
this.anotherVar = 'ipsum';
this.newTest = '....';
}