How to use the @tarojs/taro.getEnv function in @tarojs/taro

To help you get started, we’ve selected a few @tarojs/taro examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github NervJS / taro-ui / src / components / indexes / index.js View on Github external
import Taro from '@tarojs/taro'
import PropTypes from 'prop-types'
import { View, ScrollView } from '@tarojs/components'
import classNames from 'classnames'
import _findIndex from 'lodash/findIndex'

import AtComponent from '../../common/component'

import AtList from '../../components/list/index'
import AtListItem from '../../components/list/item/index'
import AtToast from '../../components/toast/index'
import { delayQuerySelector, uuid, initTestEnv, isTest } from '../../common/utils'

initTestEnv()
const ENV = Taro.getEnv()

class AtIndexes extends AtComponent {
  constructor () {
    super(...arguments)
    this.state = {
      _scrollIntoView: '',
      _scrollTop: 0,
      _tipText: '',
      _isShowToast: false,
      isWEB: Taro.getEnv() === Taro.ENV_TYPE.WEB,
    }
    // 右侧导航高度
    this.menuHeight = 0
    // 右侧导航距离顶部高度
    this.startTop = 0
    // 右侧导航元素高度
github NervJS / taro-ui-demo / src / pages / navigation / drawer / index.js View on Github external
onItemClick (index) {
    const ENV = Taro.getEnv()
    let content
    if (typeof index !== 'number') {
      content = ''
    } else {
      content = `你点击了第 ${+index + 1} 个项目`
    }
    if (ENV === 'WEAPP') content && Taro.showModal({ content, showCancel: false })
    else if (ENV === 'WEB') content && alert(content)
  }
github NervJS / taro-ui-demo / src / pages / basic / button / index.js View on Github external
onButtonClick () {
    const content = [...arguments].find(item => typeof item === 'string')
    const ENV = Taro.getEnv()
    if (ENV === 'WEAPP') Taro.showModal({ content: content || '您点击了!', showCancel: false })
    else if (ENV === 'WEB') alert(content || '您点击了!')
  }
github EasyTuan / taro-msparis / src / pages / detail / index.js View on Github external
makePhoneCall() {
    if (Taro.getEnv() === Taro.ENV_TYPE.WEB) {
      window.location.href = 'tel:123456';
    } else {
      Taro.makePhoneCall({
        phoneNumber: '123456',
      });
    }
  }
github NervJS / taro-ui / src / pages / form / picker-view / index.js View on Github external
componentDidMount () {
    const env = Taro.getEnv()
    this.setState({
      isWeapp: env === Taro.ENV_TYPE.WEAPP,
      isAlipay: env === Taro.ENV_TYPE.ALIPAY,
    })
  }