I am new to Vue and I am facing a simple issue that I can't seem to resolve. My goal is to have a mounted event in which a method is called with a specific parameter to change the "show" value of an element. Here is my code:
export default {
data(){
return {
one: false,
}
},
methods: {
show: function(el) {
this.el = true;
}
},
mounted(){
this.show(this.one)
}
}
I intend for "el" to act as a generic placeholder for any "data" name passed into the method. In the future, I may have more options like "two", "three", and "four". The purpose of the "show" method is to toggle the value from false to true based on the reference provided.
However, when accessing the show method, I encounter the error "'el' is defined but never used." The only workaround I've found involves using an if statement such as "if this.one === el {...}", but I believe there should be a better solution. Any assistance would be greatly appreciated.