0.2.0 • Published 3 years ago

weex-env v0.2.0

Weekly downloads
-
License
Apache-2.0
Repository
-
Last release
3 years ago

Weex 运行环境检测

实时检测 Weex 的运行环境和版本,支持 1.0 和 2.0 以及降级后的场景。

注 Weex 1.0 和 2.0 不是真实版本号,用来代指两个架构差异较大的版本(1.0 已开源,2.0 开发中)。

安装使用

  1. 安装 npm 包:
npm i weex-env -S
  1. 使用:
import { isWeex, isWeexV2 } from 'weex-env'

if (isWeexV2) {
  // some conditional code here
}

环境变量

  • isWeb: 是否为浏览器运行环境。
  • isWeex: 是否为 Weex 的运行环境,包括 1.0、2.0,不包括降级。
  • isWeexV1: 是否为 Weex 1.0 的原生运行环境,不包括降级。
  • isWeexV2: 是否为 Weex 2.0 的原生运行环境,不包括降级。

在各环境中的值

变量浏览器Weex1.0 原生容器Weex1.0 降级(H5)Weex2.0 原生容器Weex2.0 降级(H5)
isWeb
isWeex
isWeexV1
isWeexV2
0.2.0

3 years ago

0.1.0

4 years ago

0.0.1

4 years ago