//全局组件
<div id="app">
<counter></counter>
</div>
<template id="btn">
<div>
<button @click="arr">点击{{count}}</button>
</div>
</template>
<script>
Vue.component('counter',{
template:'#btn',
data() {
return {
count:0,
}
},
methods: {
arr(){
this.count++;
}
},
})
new Vue({
el:'#app',
})
</script>//打印结果为一个按钮依次递增
主要点:el为放置html中声明的属性,component为全局组件,template为组件模板,data可储存html中的数据是为方法,methods为方法
全局组件vue
猜你喜欢
转载自blog.csdn.net/qq_36598412/article/details/89485396
今日推荐
周排行