1👍
methods: {
handleClick () {
this.ctaCaption = this.ctaCaptions[1]
}
}
Inside event handlers, this
points to the event.target
(in your case the HTMLButtonElement
).
In your case, you want a reference to your component. You can achieve this in different ways:
Use explicit binding:
methods: {
handleClick () {
this.ctaCaption = this.ctaCaptions[1]
}.bind(this)
}
Or you can use an ES6 arrow function (these preserve the this
at the moment of definition rather than at execution time):
methods: {
handleClick: () => {
this.ctaCaption = this.ctaCaptions[1]
}
}
For a more specific and precise insight, you’d have to show the HTML snippet which uses the model code you’ve shown. Also, no line in your showcased code uses removeChild
.
- [Vuejs]-How can I get parameter from server when start vue page?
- [Vuejs]-Vuetify card with pagination
Source:stackexchange.com