Answer the question
In order to leave comments, you need to log in
How to generate variable name dynamically?
Let's say I have a method:
clickHandle: function() {
console.log(this.someVar);
}
<button @click="clickHandle()"></button>
console.log(this.someVar);
console.log(this.someOtherVar);
console.log(this.someOtherVar);
console.log(this.someOtherVar);
Answer the question
In order to leave comments, you need to log in
<button @click="clickHandle('varName')"></button>
clickHandle(varName) {
console.log(this[varName]);
console.log(this.$data[varName]); // Если только из data надо выводить
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question