微信小程序判断 开发环境 体验版 正式版

if (typeof __wxConfig == "object") {
  let version = __wxConfig.envVersion;
  console.log("当前环境:" + version)
  if (version == "develop") {
    console.log("工具或者真机 开发环境")

  } else if (version == "trial") {
    console.log("测试环境(体验版)")

  } else if (version == "release") {
    console.log("正式环境")

  }
}

uniapp也可以用

经过测试 兼容QQ小程序和微信小程序, 其他平台自测

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注