npm i @vant/weapp -S --production
步骤二 修改 app.json
将 app.json 中的 "style": "v2" 去除,小程序的新版基础组件强行加上了许多样式,难以覆盖,不关闭将造成部分组件样式混乱。
app.json
"usingComponents": {
"van-button": "miniprogram/miniprogram_npm/@vant/weapp/button/index",
"van-image":"miniprogram/miniprogram_npm/@vant/weapp/image/index",
"van-grid":"miniprogram/miniprogram_npm/@vant/weapp/grid/index",
"van-grid-item":"miniprogram/miniprogram_npm/@vant/weapp/grid-item/index",
"van-cell": "miniprogram/miniprogram_npm/@vant/weapp/cell/index",
"van-cell-group": "miniprogram/miniprogram_npm/@vant/weapp/cell-group/index",
"van-field": "miniprogram/miniprogram_npm/@vant/weapp/field/index",
"van-submit-bar": "miniprogram/miniprogram_npm/@vant/weapp/submit-bar/index",
"van-tab": "miniprogram/miniprogram_npm/@vant/weapp/tab/index",
"van-tabs": "miniprogram/miniprogram_npm/@vant/weapp/tabs/index",
"van-dialog": "miniprogram/miniprogram_npm/@vant/weapp/dialog/index"
}
project.config.json
{
...
"setting": {
...
"packNpmManually": true,
"packNpmRelationList": [
{
"packageJsonPath": "./package.json",
"miniprogramNpmDistDir": "./miniprogram/"
}
]
}
}