vue之component中的template另一种定义方式

index.html:

html>
lang="en">

    charset="UTF-8">
    </span>Title<span style="color:#e8bf6a;">
    


id="app">

main.js:

Vue.component('like', {
    template: '#like-component-tpl',
    data: function(){
        return {
            liked_count: 10,
            liked: false
        }
    },
    methods: {
        on_click: function(){
            if(!this.liked){
                this.liked_count++;
                this.liked = true
            }else{
                this.liked_count--;
                this.liked = false;
            }
        }
    }
})

new Vue({
    el: '#app'
})

你可能感兴趣的:(vue)