微信新版本通过useExtendedLib引入即可,不用使用npm构建
1、引入weui
在app.json页面,设置 "weui": true
{
"pages": [
"pages/index/index",
"pages/login/index"
],
"window": {
"backgroundTextStyle": "light",
"navigationBarBackgroundColor": "#fff",
"navigationBarTitleText": "Weixin",
"navigationBarTextStyle": "black"
},
"style": "v2",
"sitemapLocation": "sitemap.json",
"useExtendedLib": {
"weui": true
}
}
2、在要使用组件的.json页面注册组件,这里使用了徽章组件
{
"usingComponents": {
"mp-badge": "weui-miniprogram/badge/badge"
}
}
3、在页面的.wxml页面使用组件
<mp-badge content="8"></mp-badge>
效果如下: