How to use the @tarojs/taro.ENV_TYPE 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 EasyTuan / taro-msparis / src / pages / home / index.js View on Github external
render() {
    const { banner, brands, products_list, effects } = this.props;
    return (
      
    );
  }
}
github NervJS / taro-ui / src / components / tabs / index.js View on Github external
updateState = idx => {
    if (this.props.scroll) {
      // 标签栏滚动
      switch (ENV) {
        case Taro.ENV_TYPE.WEAPP:
        case Taro.ENV_TYPE.ALIPAY:
        case Taro.ENV_TYPE.SWAN:
          const index = Math.max(idx - 1, 0)
          this.setState({
            _scrollIntoView: `tab${index}`
          })
          break

        case Taro.ENV_TYPE.WEB: {
          const index = Math.max(idx - 1, 0)
          const prevTabItem = this.tabHeaderRef.childNodes[index]
          prevTabItem && this.setState({
            _scrollTop: prevTabItem.offsetTop,
            _scrollLeft: prevTabItem.offsetLeft
          })
          break
        }
github NervJS / taro-ui-demo / src / pages / view / tag / index.js View on Github external
onClick (data) {
    const { tagList } = this.state
    const findIndex = this.state.tagList.findIndex(item => item.name === data.name)
    const active = !tagList[findIndex].active
    tagList[findIndex].active = active
    const content = `您点击的 tag 标签名是:${data.name},点击前是否选中:${data.active},点击后:${active}`
    this.setState({ tagList })
    if (Taro.getEnv() === Taro.ENV_TYPE.WEAPP) Taro.showModal({ content, showCancel: false })
    else if (Taro.getEnv() === Taro.ENV_TYPE.WEB) alert(content)
    console.log(data)
  }
github EasyTuan / taro-msparis / src / pages / detail / index.js View on Github external
goToPage = e => {
    if (Taro.getEnv() === Taro.ENV_TYPE.WEB) {
      Taro.navigateTo({
        url: e.currentTarget.dataset.url,
      });
    } else {
      Taro.switchTab({
        url: e.currentTarget.dataset.url,
      });
    }
  };
github NervJS / taro-ui / src / components / image-picker / index.js View on Github external
handleRemoveImg = idx => {
    const { files = [] } = this.props
    if (ENV === Taro.ENV_TYPE.WEB) {
      window.URL.revokeObjectURL(files[idx].url)
    }
    const newFiles = files.filter((file, i) => i !== idx)
    this.props.onChange(newFiles, 'remove', idx)
  }
github NervJS / taro-ui / src / components / float-button / index.js View on Github external
constructor () {
    super(...arguments)
    const isWEAPP = Taro.getEnv() === Taro.ENV_TYPE.WEAPP
    const offset = isWEAPP ? parseInt(Taro.pxTransform(this.props.size).replace('rpx')) : this.props.size
    const windowWidth = isWEAPP ? Taro.getSystemInfoSync().windowWidth : window.innerWidth
    const windowHeight = isWEAPP ? Taro.getSystemInfoSync().windowHeight : window.innerHeight
    this.state = {
      position: {
        left: `${(windowWidth * 0.85) - offset}px`,
        top: `${(windowHeight * 0.90) - offset}px`
      },
      offset,
      movableRangeWidth: (windowWidth * 0.95) - (2 * offset),
      movableRangeHeight: (windowHeight * 0.95) - (2 * offset),
      backgroundColor: this.props.backgroundColor,
      isWEAPP,
    }
  }
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,
    })
  }
github NervJS / taro-ui / src / pages / basic / button / index.js View on Github external
import Taro from '@tarojs/taro'
import { View, Form, Text } from '@tarojs/components'
import { AtButton, AtForm, AtFab } from 'taro-ui'
import DocsHeader from '../../components/doc-header'
import './index.scss'

export default class ButtonPage extends Taro.Component {
  config = {
    navigationBarTitleText: 'Taro UI'
  }

  state = {
    isWEAPP: Taro.getEnv() === Taro.ENV_TYPE.WEAPP,
    isALIPAY: Taro.getEnv() === Taro.ENV_TYPE.ALIPAY,
  }

  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 || '您点击了按钮!')
  }

  onShareAppMessage () {
    return {
      title: 'Taro UI',
      path: '/pages/index/index',
      imageUrl: 'http://storage.360buyimg.com/mtd/home/share1535013100318.jpg'
    }
github NervJS / taro-ui / src / components / noticebar / index.js View on Github external
constructor () {
    super(...arguments)
    const animElemId = `J_${Math.ceil(Math.random() * 10e5).toString(36)}`
    this.state = {
      show: true,
      animElemId,
      dura: 15,
      isWEAPP: Taro.getEnv() === Taro.ENV_TYPE.WEAPP,
      isALIPAY: Taro.getEnv() === Taro.ENV_TYPE.ALIPAY,
      isWEB: Taro.getEnv() === Taro.ENV_TYPE.WEB,
    }
  }
github NervJS / taro-ui-demo / src / pages / basic / button / index.js View on Github external
import Taro from '@tarojs/taro'
import { View, Form } from '@tarojs/components'

import { AtButton, AtForm } from 'taro-ui'
import DocsHeader from '../../components/doc-header'

import './index.scss'

export default class ButtonPage extends Taro.Component {
  config = {
    navigationBarTitleText: 'Taro UI'
  }

  state = {
    isWEAPP: Taro.getEnv() === Taro.ENV_TYPE.WEAPP,
    isALIPAY: Taro.getEnv() === Taro.ENV_TYPE.ALIPAY,
  }

  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 || '您点击了!')
  }

  onShareAppMessage () {
    return {
      title: 'Taro UI',
      path: '/pages/index/index',
      imageUrl: 'http://storage.360buyimg.com/mtd/home/share1535013100318.jpg'
    }
  }