|
| 1 | +# `react-native-smartbar` |
| 2 | +可能是最好的tabbar。 |
| 3 | + |
| 4 | +>### **开始** |
| 5 | +
|
| 6 | +- 效果展示 |
| 7 | + |
| 8 | +  |
| 9 | + |
| 10 | +- 显示/隐藏 |
| 11 | + |
| 12 | +  |
| 13 | + |
| 14 | +- 只显示图片 |
| 15 | + |
| 16 | + 如果你希望只显示图片, 忽略此项属性即可: [text(TabBar.Item)] |
| 17 | + |
| 18 | +- 只显示文字 |
| 19 | + |
| 20 | + 如果你希望只显示文字, 忽略此项属性即可: [image(TabBar.Item)] |
| 21 | +  |
| 22 | + |
| 23 | + |
| 24 | + |
| 25 | +>### **文档** |
| 26 | +
|
| 27 | +- TabBar(底部bar) |
| 28 | + |
| 29 | +| 属性 | 类型 | 必须 | 描述 | 例子 | |
| 30 | +| ----------- | ------ | -------- | ---------------------------- | ----------------------------- | |
| 31 | +| activeColor | string | 否 | 激活颜色 | activeColor={'#FE985B'} | |
| 32 | +| toggleBar | bool | 否 | 显示与隐藏 | toggleBar={this.state.toggle} | |
| 33 | +| height | number | 否 | 高度,默认高度45px | height={50} | |
| 34 | +| index | number | 否 | 跳转至指定路由 | index={this.state.index} | |
| 35 | +| style | style | 否 | 自定义样式 | style={{height: 500}} | |
| 36 | + |
| 37 | + |
| 38 | +- TabBar.Item(底部bar的每一个子项) |
| 39 | + |
| 40 | +| 属性 | 类型 | 必须 | 描述 | 例子 | |
| 41 | +| ------------ | ------ | -------- | ---------------- | --------------------------------- | |
| 42 | +| icon | image | 否 | 默认图标(图片) | icon={require('./img/abc.png')} | |
| 43 | +| selectedIcon | image | 否 | 激活时图标(图片) | icon={require('./img/abc_2.png')} | |
| 44 | +| text | string | 否 | 默认文字 | text={'List'} | |
| 45 | +| style | style | 否 | 自定义样式 | style={{height: 500}} | |
| 46 | + |
| 47 | + |
| 48 | + |
| 49 | +>### **特点** |
| 50 | +
|
| 51 | +1. 简单敏捷的控制显示/隐藏 |
| 52 | + |
| 53 | + ```javascript |
| 54 | + <TabBar |
| 55 | + // ... |
| 56 | + ref={tabbar=> this.tabbar=tabbar} |
| 57 | + > |
| 58 | + |
| 59 | + // 使用句柄的函数控制 |
| 60 | + this.tabbar.toggleBar() |
| 61 | + |
| 62 | + // 或是设置一个布尔值 |
| 63 | + this.tabbar.toggleBar(true) |
| 64 | + this.tabbar.toggleBar(false) |
| 65 | + ``` |
| 66 | + |
| 67 | + 或者使用属性的方式: |
| 68 | + |
| 69 | + ```javascript |
| 70 | + <TabBar |
| 71 | + // ... |
| 72 | + toggleBar={this.state.toggle} |
| 73 | + > |
| 74 | + |
| 75 | + // toggle |
| 76 | + componentWillReceiveProps (nextProps){ |
| 77 | + this.setState({ |
| 78 | + toggle: nextProps.toggle |
| 79 | + }) |
| 80 | + } |
| 81 | + |
| 82 | + ``` |
| 83 | + |
| 84 | +2. 标准的指定路由跳转方式: |
| 85 | + ```javascript |
| 86 | + <TabBar |
| 87 | + // ... |
| 88 | + ref={tabbar=> this.tabbar=tabbar} |
| 89 | + > |
| 90 | + |
| 91 | + // 使用句柄的函数跳转 |
| 92 | + this.tabbar.jumpToIndex(index) |
| 93 | + |
| 94 | + ``` |
| 95 | + |
| 96 | + 或者通过设置属性的方式跳转: |
| 97 | + |
| 98 | + ```javascript |
| 99 | + <TabBar |
| 100 | + // ... |
| 101 | + index={this.state.index} |
| 102 | + > |
| 103 | + |
| 104 | + // jump |
| 105 | + componentWillReceiveProps (nextProps){ |
| 106 | + this.setState({ |
| 107 | + index: nextProps.index |
| 108 | + }) |
| 109 | + } |
| 110 | + |
| 111 | + ``` |
| 112 | + |
| 113 | +3. 可扩展的样式: |
| 114 | + |
| 115 | + 你可以为tabbar自定义任何样式: |
| 116 | + ```javascript |
| 117 | + <TabBar |
| 118 | + // ... |
| 119 | + style={{...}} |
| 120 | + > |
| 121 | + <TabBar.Item |
| 122 | + // ... |
| 123 | + style={{...}} |
| 124 | + > |
| 125 | + <Index /> |
| 126 | + </TabBar.Item> |
| 127 | + </TabBar> |
| 128 | + |
| 129 | + ``` |
| 130 | + |
| 131 | + |
| 132 | +>### **使用例子** |
| 133 | + |
| 134 | + 参见 /example |
| 135 | + |
| 136 | +>### **支持** |
| 137 | + |
| 138 | +- MAIL `(# = @) => nanazuimeng123#gmail.com` |
| 139 | +- [ISSUES](https://github.com/WittBulter/react-native-smartbar/issues) |
| 140 | + |
| 141 | + |
| 142 | + |
| 143 | + |
| 144 | + |
| 145 | + |
| 146 | + |
| 147 | + |
| 148 | + |
| 149 | + |
| 150 | + |
| 151 | + |
| 152 | + |
| 153 | + |
| 154 | + |
| 155 | + |
| 156 | + |
| 157 | + |
| 158 | + |
| 159 | + |
0 commit comments