微信小程序如何判断开发环境

const accountInfo = wx.getAccountInfoSync();
accountInfo.miniProgram.envVersion会有三个值:

  1. develop:开发版(正常开发工具,测试时)
  2. trial:体验版
  3. 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)
  }

你可能感兴趣的:(微信小程序,酷酷的刘,小程序,微信小程序,微信小程序开发环境)