const accountInfo = wx.getAccountInfoSync();
accountInfo.miniProgram.envVersion会有三个值:
- develop:开发版(正常开发工具,测试时)
- trial:体验版
- release:正式版
onLaunch() {
const accountInfo = wx.getAccountInfoSync();
switch (accountInfo.miniProgram.envVersion) {
case 'develop':
this.globalData.url = 'http://192.168.0.252:3000/api'; // 宁
break;
case 'trial':
this.globalData.url = 'https://www.baidu.com/api';
break;
case 'release':
this.globalData.url = 'https://www.qq.com/api';
break;
default:
this.globalData.url = 'https://www.360.com/api';
break;
}
console.log(accountInfo)
}