全局组件和局部组件

时间:2020-06-04 00:01:16   收藏:0   阅读:58
// 全局组件和局部组件

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) {

        }
      }
    }
  }
})

  

原文:https://www.cnblogs.com/glfan/p/13040892.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!