Skip to content

isWeb 环境判断建议与 isMiniApp 互斥 #295

@xieshiyi

Description

@xieshiyi

各个api的env判断中web环境判断条件都是最前置的。
但是在支付宝小程序开发过程中,IDE调试时,env.isWeb = true,导致后续逻辑都不正确。
同时env.isMiniApp = true,建议web环境判断更严谨些。

import uni from '@uni/apis';
console.log(uni.application.getApp(), uni.env.isWeb);

打印结果:
image

正确应该是返回 getApp()
image

运行环境:支付宝小程序

// mini.project.json
{
  "format": 2,
  "miniprogramRoot": "src",
  "compileOptions": {
    "component2": true,
    "typescript": true,
    "less": true,
    "enableNodeModuleBabelTransform": true
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions