Vue3+Ts+Vite的uniapp小程序项目中引入最新vant-weapp v1.11.2并且以后更新版本全部可用
由于vant-weapp是针对微信小程序原生开发的使用在uniapp中并不能使用npm i 方式引入vant-weapp,所以采用手动引入的方式
git clone https://github.com/youzan/vant-weapp.git
2.在项目src文件里面创建wxcomponents
将下载的vant-weapp文件打开将里面的dist文件复制粘贴到wxcomponents
中并且重命名为vant(这样更好识别)
3.打开app.vue文件在<style lang="scss">
里添加@import '@/wxcomponents/vant/common/index.wxss'
<style lang="scss">
@import '@/wxcomponents/vant/common/index.wxss'
@import '/wxcomponents/vant/common/index.wxss'
...省略
</style>
4.打开pages.json
选择你是想全局还是局部引入
"globalStyle": {
...省略
"usingComponents": {
"van-button": "/wxcomponents/vant/button/index",
"van-cell": "/wxcomponents/vant/cell/index",
"van-cell-group": "/wxcomponents/vant/cell-group/index",
"van-icon": "/wxcomponents/vant/icon/index",
"van-image": "/wxcomponents/vant/image/index",
"van-row": "/wxcomponents/vant/row/index",
"van-col": "/wxcomponents/vant/col/index",
"van-popup": "/wxcomponents/vant/popup/index",
"van-toast": "/wxcomponents/vant/toast/index",
"van-card": "/wxcomponents/vant/card/index"
}
{
"path": "pages/index/index",
"style": {
"navigationStyle": "custom",
"navigationBarTextStyle": "white",
"navigationBarTitleText": "首页",
"usingComponents": {
"van-button": "/wxcomponents/vant/button/index",
}
}
}