当前位置: 代码迷 >> 综合 >> vue学习(五)组件
  详细解决方案

vue学习(五)组件

热度:46   发布时间:2023-10-17 19:28:27.0

1.简单案例

 

<div id="components-demo"><button-counter></button-counter>
</div>
new Vue({ el: '#components-demo' })

 

// 定义一个名为 button-counter 的新组件
Vue.component('button-counter', {data: function () {return {count: 0}},template: '<button v-on:click="count++">You clicked me {
       { count }} times.</button>'
})
  相关解决方案