全局组件和局部组件

// 全局组件和局部组件

Vue.component('组件名',配置对象)
Vue.component('global', {
  template: `
   <div>
     <h1>全局组件<h1>
     // 局部组件
     <gl-demo></gl-demo>
   </div>
  `,
  data() {
    return {}
  }
 ,
  // 局部组件
  components: {
    // 组件名 组件的配置对象
    'gl-demo': {
      template:`
       <div>
         局部组件
       </div>
      `,
      // 组件中的data是一个函数,返回一个对象
      data() {
        return {}
      },
      methods: {},
      computed: {},
      watch: {
        listArr: {
          deep: true,
          handler(newValue,oldValue) {

          }
        },
        msg(newValue,oldValue) {

        }
      }
    }
  }
})

  

posted @ 2020-06-03 23:52  糖锡  阅读(177)  评论(0)    收藏  举报