uni-app 引入 wxcomponents 组件无效
uni-app 引入 wxcomponents 组件无效
开发环境 | 版本号 | 项目创建方式 |
---|---|---|
Windows | 64位 | HBuilderX |
产品分类:uniapp/H5
浏览器平台:Chrome
浏览器版本:版本 100.0.4896.127(正式版本)(64 位)
示例代码:
- index.js
Component({
properties: {
// 这里定义了 innerText 属性,属性值可以在组件使用时指定
innerText: {
type: String,
value: 'default value',
}
},
data: {
// 这里是一些组件内部数据
someData: {}
},
methods: {
// 这里是一个自定义方法
customMethod: function(){}
}
});
- index.json
{
"component": true
}
- index.wxml
<view class="list">
<view>aaaaaaaaaaaaaaaaaaa</view>
<view>bbbbbbbbbbbbbbbbbbb</view>
</view>
- index.wxss
.list {
background-color: #c00;
}
- pages.json
"globalStyle": {
"navigationBarTextStyle": "black",
"navigationBarTitleText": "uni-app",
"navigationBarBackgroundColor": "#F8F8F8",
"backgroundColor": "#F8F8F8",
"usingComponents": {
"my-list": "/wxcomponents/lists/index"
}
},
或页面style
{
"path" : "pages/list/list",
"style" :
{
"navigationBarTitleText": "列表",
"enablePullDownRefresh": true
// "usingComponents": {
// "my-list": "/wxcomponents/lists/index"
// }
}
}
- 页面vue
<view>
<text>11111111111</text>
<my-list></my-list>
</view>
操作步骤:
运行到h5或app都报:
uni-h5.es.js:14118 [Vue warn]: Failed to resolve component: my-list
If this is a native custom element, make sure to exclude it from component resolution via compilerOptions.isCustomElement.
预期结果:
希望h5或app能正常编译小程序自定义组件(wxcomponents组件)
实际结果:
uni-h5.es.js:14118 [Vue warn]: Failed to resolve component: my-list
If this is a native custom element, make sure to exclude it from component resolution via compilerOptions.isCustomElement.
at <List>
at <AsyncComponentWrapper>
at <PageBody>
at <Page>
at <Anonymous>
at <KeepAlive>
at <RouterView>
at <Layout>
at <App>
bug描述:
-
环境vue3 (setup)
-
wxcomponents定义
结构
index.js
index.json
index.wxml
-
pages.json (globalStyle、页面style都有配置usingComponents,配置内容一模一样)
-
vue页面引入
-
h5、app运行效果(无效)
速求解法???
更多关于uni-app 引入 wxcomponents 组件无效的实战教程也可以访问 https://www.itying.com/category-93-b0.html