微信小程序开发之区分运行环境

发布于 5 年前作者 xiulan971628 次浏览最后编辑 5 年前来自 share
const accountInfo = wx.getAccountInfoSync();
const env = accountInfo .miniProgram.envVersion;
if (!env) {
  console.error("获取运行环境失败")
}
const baseApi = {
  //开发版
  develop:"开发域名",
  //体验版
  trial:"体验版本域名",
  //正式版
  release:"正式版本域名"
};
//导出用来请求拼接域名
export const baseUrl = baseApi[env]
0 回复
暂无回复