npm init npm i @vant/weapp -S --production
{ ... "setting": { ... "packNpmManually": true, "packNpmRelationList": [ { "packageJsonPath": "./package.json", "miniprogramNpmDistDir": "./miniprogram/" } ] } }
打开微信开发者工具,点击 工具 -- 构建 npm,构建完成后,可引入组件
以 button 组件为例,在app.json或index.json中配置 button 对应的路径即可
// app.json { ... "usingComponents": { "van-button": "@vant/weapp/button/index" } }
<van-button type="primary">van按钮</van-button>