Reputation: 3533
Here is a very simple Vuejs component which attempts to capture the click event of a span:
nativeOn: {
click: function (event) {
alert('clicked')
}
},
… and here's the demo, but it does not work, what I'm missing here?
Upvotes: 1
Views: 1185
Reputation: 73649
As you are registering the event on span
element, you have to use on
option as follows:
Vue.component('hello', {
render: function(createElement) {
return createElement("span", {
on: {
click: function(event) {
alert('clicked')
}
},
}, "Hello ")
}
})
see a live demo on jsfiddle.
Upvotes: 4