1. // 定义一个名为 button-counter 的新组件
    2. Vue.component('button-counter', {
    3. data: function () {
    4. return {
    5. count: 0
    6. }
    7. },
    8. template: '<button v-on:click="count++">You clicked me {{ count }} times.</button>'
    9. })

    组件是可复用的Vue实例,与new Vue 接收相同的选项,如 data、computed、watch、methods以及生命周期钩子、

    • 全局注册
      • Vue.component
    • 局部注册

    通过 Prop 向子组件传递数据
    使用 v-bind来动态传递 prop