On this page
https://v2.vuejs.org/v2/guide/events.html
I can set up methods like so
var example2 = new Vue({
el: '#example-2',
data: {
name: 'Vue.js'
},
// define methods under the `methods` object
methods: {
greet: function (event) {
// `this` inside methods points to the Vue instance
alert('Hello ' + this.name + '!')
// `event` is the native DOM event
if (event) {
alert(event.target.tagName)
}
}
}
})
// you can invoke methods in JavaScript too
example2.greet() // => 'Hello Vue.js!'
but if I make a component, the methods don't work
Vue.component('ti-user-card', {
data: function () {
return {
pEmail: "[email protected]"
};
},
template: '#vUserCard',
methods : {
mEmail : function(event) {
window.location.href = "mailto:" + this.pEmail;
}
}
});
html
<template id="vUserCard">
<button v-bind:click="mEmail">
Email
</button>
</template>
<div id="app">
<ti-user-card></ti-user-card>
</div>
how can I fix this?
Thanks