classnames & React & taro
classnames
https://www.npmjs.com/package/classnames
demo
https://github.com/NervJS/taro-ui/blob/dev/src/components/tabs/index.tsx
import classNames from 'classnames'
import PropTypes, { InferProps } from 'prop-types'
import { AtTabsProps, AtTabsState } from 'types/tabs'
import { ScrollView, View } from '@tarojs/components'
import { CommonEvent, ITouchEvent } from '@tarojs/components/types/common'
import Taro from '@tarojs/taro'
import AtComponent from '../../common/component'
import { isTest, uuid } from '../../common/utils'
ES6 Computed Property
https://tylermcginnis.com/computed-property-names/
// Computed property names (ES2015)
let i = 0
let a = {
['foo' + ++i]: i,
['foo' + ++i]: i,
['foo' + ++i]: i
}
console.log(a.foo1) // 1
console.log(a.foo2) // 2
console.log(a.foo3) // 3
let param = 'size'
let config = {
[param]: 12,
['mobile' + param.charAt(0).toUpperCase() + param.slice(1)]: 4
}
console.log(config) // {size: 12, mobileSize: 4}