TabBarBottom.jsx 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. import React ,{Component} from 'react';
  2. import { TabBar } from 'antd-mobile';
  3. import './TabBarBottom.css'
  4. class TabBarBottom extends Component {
  5. constructor(props) {
  6. super(props);
  7. this.state = {
  8. selectedTab: 'index',
  9. hidden: false,
  10. fullScreen: true
  11. };
  12. this.handleChange=this.handleChange.bind(this)
  13. }
  14. //要保留,勿动
  15. renderContent(page){}
  16. handleChange(page){
  17. this.props.changePage(page)
  18. }
  19. render() {
  20. //这里渲染一次
  21. const handleChange=this.handleChange
  22. return (
  23. <div style={this.state.fullScreen ? { position: 'absolute', height: '100%', width: '100%', bottom: 0 } : { height: 400 }} className="TabBarBottom">
  24. <TabBar
  25. unselectedTintColor="#949494"
  26. tintColor="#33A3F4"
  27. barTintColor="white"
  28. hidden={this.state.hidden}
  29. >
  30. <TabBar.Item
  31. title="首页"
  32. key="Life"
  33. icon={<div style={{
  34. width: '22px',
  35. height: '22px',
  36. background: 'url(https://wly-1254337200.cos.ap-guangzhou.myqcloud.com/home.svg) center center / 21px 21px no-repeat' }}
  37. />
  38. }
  39. selectedIcon={<div style={{
  40. width: '22px',
  41. height: '22px',
  42. background: 'url(https://wly-1254337200.cos.ap-guangzhou.myqcloud.com/home_s.svg) center center / 21px 21px no-repeat' }}
  43. />
  44. }
  45. selected={this.state.selectedTab === 'index'}
  46. onPress={() => {
  47. handleChange('home')
  48. this.setState({
  49. selectedTab: 'index',
  50. });
  51. }}
  52. data-seed="logId"
  53. >
  54. {this.renderContent('index')}
  55. </TabBar.Item>
  56. <TabBar.Item
  57. icon={
  58. <div style={{
  59. width: '22px',
  60. height: '22px',
  61. background: 'url(https://wly-1254337200.cos.ap-guangzhou.myqcloud.com/user.svg) center center / 21px 21px no-repeat' }}
  62. />
  63. }
  64. selectedIcon={
  65. <div style={{
  66. width: '22px',
  67. height: '22px',
  68. background: 'url(https://wly-1254337200.cos.ap-guangzhou.myqcloud.com/user_s.svg) center center / 21px 21px no-repeat' }}
  69. />
  70. }
  71. title="我的"
  72. key="user"
  73. selected={this.state.selectedTab === 'user'}
  74. onPress={() => {
  75. handleChange('user')
  76. this.setState({
  77. selectedTab: 'user',
  78. });
  79. }}
  80. >
  81. {this.renderContent('user')}
  82. </TabBar.Item>
  83. </TabBar>
  84. </div>
  85. );
  86. }
  87. }
  88. export default TabBarBottom