Changeset View
Changeset View
Standalone View
Standalone View
src/components/tabs/index.jsx
- This file was added.
import Taro, { Component } from '@tarojs/taro' | |||||
import { View } from '@tarojs/components' | |||||
import './index.scss' | |||||
class Tabs extends Component { | |||||
static defaultProps = { | |||||
tabList: [], | |||||
current: 0, | |||||
onClick: () => { } | |||||
} | |||||
handleClick () { | |||||
this.props.onClick(...arguments) | |||||
} | |||||
render () { | |||||
const { tabList, current } = this.props | |||||
return ( | |||||
<View className='rba-tabs_layout'> | |||||
{tabList.map((item, index) => ( | |||||
<View | |||||
className={`tabs_item ${current === index ? 'tabs_item--active' : ''}`} | |||||
key={item.title} | |||||
onClick={this.handleClick.bind(this, index)} | |||||
> | |||||
<View className='tab-title'> | |||||
{item.title} | |||||
{item.isShowBadge && <View className='tab-badge' />} | |||||
</View> | |||||
<View style={{ background: current === index ? '#FF7632' : 'transparent' }} className='line' /> | |||||
</View> | |||||
))} | |||||
</View> | |||||
) | |||||
} | |||||
} | |||||
export default Tabs | |||||
No newline at end of file |
Content licensed under Creative Commons Attribution-ShareAlike 3.0 (CC-BY-SA) unless otherwise noted; code licensed under GNU General Public License (GPL) or other open source licenses. By using this site, you agree to the Terms of Use, Privacy Policy, and Code of Conduct. · Wikimedia Foundation · Privacy Policy · Code of Conduct · Terms of Use · Disclaimer · CC-BY-SA · GPL