I have component
and i want run method after click
<my-component @click="showOtherDiv"></my-component>
i have this method on main app methods
var app = new Vue({
el: '#app',
data: {},
methods: {
showOtherDiv : function(){
alert('Some message');
}
}
});
but seems like "click" not works on full component
Register your component, and declare the handler method inside:
Vue.component('my-component', {
// ...
methods: {
showOtherDiv : function(){
alert('Some message');
}
}
});
Add the .native modifier to the event name:
<my-component @click.native="showOtherDiv"></my-component>
From the docs:
Binding Native Events to Components
[…] when you want to listen for a native event on the root element of a component […] you can use the
.nativemodifier forv-on.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With