index.jsx 802B

123456789101112131415161718192021222324252627282930313233343536373839
  1. import React from 'react'
  2. import './style.less'
  3. export default (props) => {
  4. const { extClass = '', current, onChange, children } = props
  5. const handleTabChange = (e, index) => {
  6. if (e) {
  7. e.detail = {
  8. ...e.detail || {},
  9. index,
  10. }
  11. // Object.assign(e.detail, { index })
  12. }
  13. if (onChange) {
  14. onChange(e)
  15. }
  16. }
  17. const className = `weui-tabbar cust-tabbar ${extClass}`
  18. return (
  19. <view className={className}>
  20. {
  21. React.Children.toArray(children).map((child, index) => {
  22. const itemClass = `weui-tabbar__item cust-tabbar-item`
  23. return (
  24. <view className={itemClass} onClick={(e) => handleTabChange(e, index)}>
  25. {child}
  26. </view>
  27. )
  28. })
  29. }
  30. </view>
  31. )
  32. }