0
You just have to pass your method on the v-on:click function defined on your HTML tag. See:
<button v-on:click="sendMessage()" value='Send'>Send Message</button>
methods: {
sendMessage(e) {
console.log(`Hello, world from the button ${e.target.value}`)
},
},
mounted: {
this.sendMessage()
}
Where e
is the event dispatched when you click the button.
-1
I’ll do this the old fashioned way.
Using Jquery (or native JS)
$(document).on('click', 'yourCssClass', function(e){
yourJsCode;
});
- [Vuejs]-How to create redirect after auth user, vue.js?
- [Vuejs]-Why do my components not updating reactively in this vuejs application?
Source:stackexchange.com