1***@qq.com
1***@qq.com
  • 发布:2023-07-28 15:58
  • 更新:2023-07-29 12:29
  • 阅读:210

【报bug】H5 动态注册组件,在页面能渲染出来,在app端渲染不出来

分类:uni-app
        async getComponent(name = 'job-content-records') {  
            console.log('进到这里了吗')  
            var context = await require.context('@/components', true, /\index.vue$/)  
            var keys = context.keys()  
            // console.log(keys, '文件类型')  
            const moduleName = keys.find(key=> key.includes(name));  
            // console.log(moduleName, '得到了组件路径')  
            var myComponent = moduleName ? context(moduleName).default : null;  
            // console.log(myComponent, '组件得到了')  
            const vueComponent = await Vue.component(name, myComponent);  
            console.log(vueComponent, '得到了注册的组件')  
        },  

以上是页面局部注册组件,在h5页面是可以展示组件的,在app端组件是不显示的

2023-07-28 15:58 负责人:无 分享
已邀请:
hhyang

hhyang - 如有问题,请添加QQ1606726660 备注付费咨询

这不是bug,本身非h5端就不支持 如果你想跨段实现动态组件可以查看 uni-simple-router

  • 1***@qq.com (作者)

    component是显示支持的

    2023-08-09 17:30

要回复问题请先登录注册