function initApp(){
return new Promise((resolve) => {
try{
uni.getEnv((res) => {
console.log('打印1',JSON.stringify(res));
store.commit('SET_APP_ENV', !!res.plus)
resolve('success')
})
}catch(err){
resolve('failed')
}
})
}

- 发布:2025-02-21 20:41
- 更新:2025-02-21 20:41
- 阅读:15
【报Bug】uniapp使用web-view内嵌h5页面,在h5页面中使用uni.getEnv获取当前环境,一直返回{h5:true},延迟一秒才能打印出{plus:true}
产品分类: uniapp/App
PC开发环境操作系统: Windows
PC开发环境操作系统版本号: 22631.4751
HBuilderX类型: 正式
HBuilderX版本号: 4.45
手机系统: Android
手机系统版本号: Android 10
手机厂商: 华为
手机机型: nova6 se
页面类型: vue
vue版本: vue2
打包方式: 云端
项目创建方式: HBuilderX
操作步骤:
预期结果:
{plus:true}
{plus:true}
实际结果:
{h5:true}
{h5:true}
bug描述:
uniapp使用web-view内嵌h5页面,在h5页面中使用uni.getEnv获取当前环境,一直返回{h5:true},延迟一秒才能打印出{plus:true}
如图:
打印1期望结果:{plus:true}
实际打印结果:{h5:true}
