// 定义一个名为 button-counter 的新组件Vue.component('button-counter', {data: function () {return {count: 0}},template: '<button v-on:click="count++">You clicked me {{ count }} times.</button>'})
组件是可复用的Vue实例,与new Vue 接收相同的选项,如 data、computed、watch、methods以及生命周期钩子、
- 全局注册
- Vue.component
- 局部注册
通过 Prop 向子组件传递数据
使用 v-bind来动态传递 prop
