2023-02-28 Unknown custom element: <uni-view> - did you register the component correctly? For recursive components, make sure to provide the "name" option.

问题描述:vue h5业务,之前是由wepy转成uniapp,报错内容为:

Unknown custom element: <uni-view> - did you register the component correctly? For recursive components, make sure to provide the "name" option.

解释:未知的自定义元素:<uni-view>-是否正确注册了组件?对于递归组件,请确保提供“name”选项。

注:我已经明确注册了该组件,并且在之前的项目里是正常运行的没有报错的,转成uniapp后,就报错了。

原因:你在main.js的配置中有一个配置覆盖了uni-app 的原有配置,因此导致Vue控制台报错找不到自定义组件,简而言之:配置出错。

解决方案:在你的vue项目中找到入口文件,即main.js,你会发现在里面有一行关于Vue.config.ignoredElements的配置代码。我的是这样的:

Vue.config.ignoredElements = ['wx-open-launch-weapp']

但是这样写并不正确,正确写法为:

Vue.config.ignoredElements = ['wx-open-launch-weapp', /^uni-/]

参考文档:https://dandelioncloud.cn/article/details/1419660973564301313/

posted @ 2023-02-28 16:11  叶乘风  阅读(930)  评论(0编辑  收藏  举报