javascript - vue component event problem
某草草
某草草 2017-05-18 11:01:42
0
1
428

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)
        }
    }
});
某草草
某草草

reply all(1)
大家讲道理

Is your cook in another file? Then you need to import the file of the registered component below.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template