How do I extend another VueJS component in a single-file component? (ES6 vue-loader)

后端 未结 5 850
迷失自我
迷失自我 2020-12-14 14:47

I am using vue-loader (http://vuejs.github.io/vue-loader/start/spec.html) to construct my *.vue single-file components, but I am having trouble with the process

5条回答
  •  轮回少年
    2020-12-14 15:30

    After some testing, the simple solution was to be sure to export a Vue.extend() object rather than a plain object for any component being extended.

    In my case, the base component:

    import Vue from 'vue'
    
    export default Vue.extend({ [component "Foo" definition] })
    

    and the extended component:

    import Foo from './Foo'
    
    export default Foo.extend({ [extended component definition] })
    

提交回复
热议问题