-
Notifications
You must be signed in to change notification settings - Fork 459
Description
依赖版本:
"dependencies": {
"kbone-ui": "^1.0.14",
"vue": "^3.5.0"
}
自定义元素配置:
{
test: /.vue$/,
use: [
'thread-loader',
{
loader: 'vue-loader',
options: {
compilerOptions: {
preserveWhitespace: false,
isCustomElement: (tag) => {
return /wx-/.test(tag) // (return true)
}
}
}
},
'vue-improve-loader',
]
}
除了webpack中的配置,入口处也加上:
app.config.compilerOptions.isCustomElement = tag => {
return tag.startsWith('wx');
};
都无效
vue代码:
`
<wx-button type="default">页面次要操作 Normal</wx-button>
<wx-button type="default" disabled="true">页面次要操作 Disabled</wx-button>
<wx-button type="warn">警告类操作 Normal</wx-button>
<wx-button type="warn" disabled="true">警告类操作 Disabled</wx-button>
<view class="button-sp-area">
<wx-button type="primary" plain="true">按钮</wx-button>
<wx-button type="primary" disabled="true" plain="true">不可点击的按钮</wx-button>
<wx-button type="default" plain="true">按钮</wx-button>
<wx-button type="default" disabled="true" plain="true">按钮</wx-button>
<wx-button class="mini-btn" type="primary" size="mini">按钮</wx-button>
<wx-button class="mini-btn" type="default" size="mini">按钮</wx-button>
<wx-button class="mini-btn" type="warn" size="mini">按钮</wx-button>
</view>
</view>
`
npm run web后:
[Vue warn]: Failed to resolve component: wx-button
Error:
Uncaught TypeError: this._parent.addItem is not a function
详情:
connectedCallback() {
super.connectedCallback();
this.parent = Object(utils_tool__WEBPACK_IMPORTED_MODULE_3["findParent"])(this, parentNode => parentNode.tagName === 'WX-CHECKBOX-GROUP');
if (this._parent) this._parent.addItem(this);
this.addEventListener('tap', this.onTap);
}
意思就是wx-checkbox-group、wx-radio-group找不到addItem方法。
直接在网页中测试是没有问题的。vue3中有问题