vue 動態加載並註冊組件且通過 render動態創建該組件

 <load-comp :config="editUserConfig1" url="page/user/Index"></oad-comp>

load-comp.vue

<script>
  export default { 
    props: {
      name: { 
      type:String,  
      default:'loadComp',
      },
      url: {
        type:String,
        default:''
      },
      config: {
        type:Object,
        default() {
          return {};
        }
      }
    },
    created() { 
      this.$options.components[this.name] = require('@/components/'+this.url+'.vue')
    },
    render: function (createElement) {
      debugger
      return createElement(this.name,{
      props: {
        config: this.config
      }
    })
    }
  }
</script> 
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章