extend创建的是一个组件构造器,而不是一个具体的组件实例,最终还是要通过Vue.component注册才可以使用
组件构造器相当于Vue.component()方法的第二个参数部分

const Loading = Vue.extend({
    template: ``,
    data () {
        return {
            hello: ''
        }
    }
})

// 注册局部组件
Vue.component('loading', Loading)

组件构造器实例化后,传入的data数据需要放在propsData中

new Loading({
    propsData: {
        hello: '你好'
    }
}).$mount('#div')

$mount()方法表示将组件挂载,#div表示挂载到id为div的DOM上

相关文章:

  • 2022-12-23
  • 2021-05-27
  • 2022-12-23
  • 2021-12-05
  • 2022-12-23
  • 2021-06-11
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-01-17
  • 2022-12-23
  • 2021-09-20
  • 2021-07-06
  • 2021-12-08
  • 2021-07-13
相关资源
相似解决方案