How to call the js object method in the vue component?
Now call triggers Uncaught TypeError: cook.tag is not a function
Uncaught TypeError: cook.tag is not a function
Where cook.tag is the external objct method, the solution
var cook={}
cook.tag = function(id) {
alert(id)
}
Vue.component('cook-tag', {
template: '<p class="cook-tag ui-nowrap-multi"><span class="tag-item" v-for="item in list" v-on:click="cookview(item)" >#{{item}}</span></p>',
data() {
return {
list:[],
}
},
props: ['tags'],
created(){
this.list = this.tags.split(",") || [];
},
methods:{
cookview:function(tag) {
cook.tag(tag)
}
}
});
Is your cook in another file? Then you need to import the file of the registered component below.