Tab

标签页组件。

Install

  1. npm install beeshell

Usage

引入方式

全部引入

  1. import { Tab } from 'beeshell';

单独引入

  1. import Tab from 'beeshell/components/Tab';

Examples

image

Code

  1. import { Tab } from 'beeshell';
  2. class App extends React.Component {
  3. constructor(props) {
  4. super(props);
  5. this.state = {
  6. value: 1,
  7. };
  8. }
  9. render() {
  10. const options = [
  11. {
  12. value: 1,
  13. label: '全部',
  14. },
  15. {
  16. value: 2,
  17. label: '已完成',
  18. },
  19. {
  20. value: 3,
  21. label: '未完成',
  22. }
  23. ];
  24. return (
  25. <View>
  26. <Tab
  27. value={this.state.value}
  28. options={options}
  29. onChange={value => this.setState({ value })}
  30. />
  31. <View>
  32. <Text>
  33. {this.state.value}
  34. </Text>
  35. </View>
  36. </View>
  37. );
  38. }
  39. }

Props

Name Type Required Default Description
threshold Number false 4 阈值,超过该值则横向滚动
options Array true [] 数据源,数组中项为对象
{label: 'xx', value: 'zz'}
label(options 中的对象的属性) String/ReactElement true null 数据源数组中的对象的属性,用于展示选项,可以是字符串或者 React 组件
value(options 中的对象的属性) Any true null 数据源数组中的对象的属性,通过该属性判读是否选中该项
value Any false null 对应数据源对象的 value 值
onChange Function false null 状态切换时的回调