@uni/env
v1.1.1
Published
[![npm](https://img.shields.io/npm/v/@uni/env.svg)](https://www.npmjs.com/package/@uni/env)
Downloads
3,768
Readme
env
Judge runtime environment
Support
Install
$ npm install @uni/env --save
Usage
import { isWeex, isWeb, isMiniApp, isNode, isWeChatMiniProgram, isByteDanceMicroApp, isBaiduSmartProgram, isKuaiShouMiniProgram } from '@uni/env';
You can also import from the big package:
import { env } from '@uni/apis';
APIS
isWeex: boolean
Checks if environment is a weex environment.
isWeb: boolean
Checks if environment is a web environment.
isMiniApp: boolean
Checks if environment is an alibaba miniprogram environment.
isWeChatMiniProgram: boolean
Checks if environment is a wechat miniprogram environment.
isByteDanceMicroApp: boolean
Checks if environment is a bytedance microapp environment.
isBaiduSmartProgram: boolean
Checks if environment is a baidu smartprogram environment.
isKuaiShouMiniProgram: boolean
Checks if environment is a kuaishou miniprogram environment.
isNode: boolean
Checks if environment is a Node.js environment.
Results in each container
Note:To judge MiniProgram env in WebView, please insert JS SDK accordingly.
| | isMiniApp | isWeChatMiniProgram | isByteDanceMicroApp | isBaiduSmartProgram | isKuaiShouMiniProgram | isWeb | isWeex | isNode | | ---------------------------- | --------- | ------------------- | ------------------ | ------------------- | --------------------- | ------ | ----- | ------ | | Alibaba MiniApp | ✔️ | ✘ | ✘ | ✘ | ✘ | ✘ | ✘ | ✘ | | Alibaba MiniApp WebView | ✔️ | ✘ | ✘ | ✘ | ✘ | ✔️ | ✘ | ✘ | | Wechat MiniProgram | ✘ | ✔️ | ✘ | ✘ | ✘ | ✘ | ✘ | ✘ | | Wechat MiniProgram WebView | ✘ | ✔️ | ✘ | ✘ | ✘ | ✔️ | ✘ | ✘ | | ByteDance MicroApp | ✘ | ✘ | ✔️ | ✘ | ✘ | ✘ | ✘ | ✘ | | ByteDance MicroApp WebView | ✘ | ✘ | ✔️ | ✘ | ✘ | ✔️ | ✘ | ✘ | | Baidu SmartProgram | ✘ | ✘ | ✘ | ✔️ | ✘ | ✘ | ✘ | ✘ | | Baidu SmartProgram WebView | ✘ | ✘ | ✘ | ✔️ | ✘ | ✔️ | ✘ | ✘ | | KuaiShou MiniProgram | ✘ | ✘ | ✘ | ✘ | ✔️ | ✘ | ✘ | ✘ | | KuaiShou MiniProgram WebView | ✘ | ✘ | ✘ | ✘ | ✔️ | ✔️ | ✘ | ✘ | | Node | ✘ | ✘ | ✘ | ✘ | ✘ | ✘ | ✘ | ✔️ | | Web | ✘ | ✘ | ✘ | ✘ | ✘ | ✔️ | ✘ | ✘ |