一、随记
🎯 问题:微信小程序在初始化项目后构建npm没有生成miniprogram_npm文件
解决办法
1、初始化npm init
2、安装依赖 npm install XXXX
3、设置project.config.json文件
## 初始化npm init
$ npm init
## 安装依赖 npm install XXXX
$ npm i
设置好project.config.json文件之后再次构建npm
开发者工具–>工具–>构建npm 就会生成 miniprogram_npm 文件夹了
## project.config.json
"packNpmManually": false,
"packNpmRelationList": [
{
"packageJsonPath": "./package.json",
"miniprogramNpmDistDir": "./"
}
]
页面中引入组件使用地址路径
{
"navigationBarTitleText": "测试页面",
"usingComponents": {
"van-image": "@vant/weapp/image/index",
"van-tag":"@vant/weapp/tag/index",
"van-cell": "@vant/weapp/cell/index",
"van-cell-group": "@vant/weapp/cell-group/index",
"van-row": "@vant/weapp/row/index",
"van-col": "@vant/weapp/col/index"
}
}