I can't call mixin method from the component, I get this error this.hello is not a function
.
I can call hello()
from Vue instance but I can't call it within the component.
What's a matter?!
<div id='vue-app'>
<cmp></cmp>
</div>
const mixin = {
methods: {
hello() {
return 'Hello World!';
}
},
created() {
console.log('Mixin Created!');
},
};
const cmp = {
created() {
console.log('From Cmp:', this.hello());
},
};
new Vue({
components: {
cmp
},
el: '#vue-app',
mixins: [mixin],
created() {
console.log('From VM:', this.hello());
},
});