- 发布:2022-07-08 09:21
- 更新:2022-07-11 20:19
- 阅读:1822
产品分类: uniapp/App
PC开发环境操作系统: Windows
PC开发环境操作系统版本号: win11
HBuilderX类型: 正式
HBuilderX版本号: 3.4.18
手机系统: Android
手机系统版本号: Android 12
手机厂商: 三星
手机机型: s20+
页面类型: nvue
vue版本: vue3
打包方式: 云端
项目创建方式: HBuilderX
示例代码:
<sn-svg :src="source1" style="width: 60rpx;height: 60rpx;margin-top: 10rpx;" />
操作步骤:
安装原生组件sn-svg云打包基座
运行到手机,页面使用了组件,控制台就会报错
安装原生组件sn-svg云打包基座
运行到手机,页面使用了组件,控制台就会报错
预期结果:
控制台没有内容
控制台没有内容
实际结果:
09:12:56.063 [Vue warn]: Failed to resolve component: sn-svg
09:12:56.084 If this is a native custom element, make sure to exclude it from component resolution via compilerOptions.isCustomElement.
09:12:56.106 at <MoIconname="plus"color="#fff"size="64">
09:12:56.127 at <FabonClick=fn>
09:12:56.148 at <Homekey=0>
09:12:56.170 at <SwiperItemclass="swiper__item"key=2>
09:12:56.191 at <Swiperclass="swiper__wrap"current=0duration=30 ...>
09:12:56.212 at <Index__pageId=1__pagePath="pages/index/index"__pageQuery={}>
09:12:56.063 [Vue warn]: Failed to resolve component: sn-svg
09:12:56.084 If this is a native custom element, make sure to exclude it from component resolution via compilerOptions.isCustomElement.
09:12:56.106 at <MoIconname="plus"color="#fff"size="64">
09:12:56.127 at <FabonClick=fn>
09:12:56.148 at <Homekey=0>
09:12:56.170 at <SwiperItemclass="swiper__item"key=2>
09:12:56.191 at <Swiperclass="swiper__wrap"current=0duration=30 ...>
09:12:56.212 at <Index__pageId=1__pagePath="pages/index/index"__pageQuery={}>
bug描述:
调用原生组件时每次都报错(组件功能正常):
[Vue warn]: Failed to resolve component: sn-svg
If this is a native custom element, make sure to exclude it from component resolution via compilerOptions.isCustomElement.
3.4.18正式版和3.5.1alpha都有这个问题。
原生组件sn-svg是官方市场的,作者也说是HB的问题
补充内容:我在main.js配置了app.config.compilerOptions.isCustomElement=tag=>true也没用
1 个回复
DCloud_UNI_WZF
compilerOptions 文档中有提到,如果使用的是附带额外构建设置的仅运行时版本,编译器选项必须通过构建工具的配置传入,所以 isCustomElement 要在 vite.config.js 中配置,可参考如下配置:
另外:customElements 默认是绑定在 window上的,所以正常讲在 App 端是无法使用的,不知道你引入的 sn-svg 有没有做特殊处理,以上配置运行到 H5 亲测有效