记录下微信小程序使用npm安装三方包,以vant-ui为例:
- 1、安装npm,配置环境变量
- 2、切换到小程序所在目录,执行
npm init -f
- 3、安装依赖包
npm i @vant/weapp -S --production
- 4、构建npm:微信小程序开发工具勾选使用npm模块,工具–>构建npm
- 5、引入组件:例:
"usingComponents": {
"van-button": "@vant/weapp/button/index"
}
- 6、使用组件
<van-button type="primary">按钮</van-button>