适用 taro 版本 3.x;开发微信小程序时,允许根据 NODE_ENV 环境配置在编译时设置不同的 appid
npm i taro-plugin-mul-appid -D
/config/[prod | dev].js
module.exports = {
env: {
NODE_ENV: '"production"',
},
mini: {
// 配置appid
appid: "xxxxxxxxxxxx",
},
};
/config/index.js
const config = {
plugins: [
[
"taro-plugin-mul-appid",
{
// 指定appid
appid: "xxxxxxxxxxxx",
// 是否修改源代码project.config.json中的appid
sourceEdit: false,
},
],
],
};