MenuIcon.jsx 869B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import React from 'react';
  2. import Taro from '@tarojs/taro';
  3. import { View } from '@tarojs/components';
  4. import RatioView from './RatioView';
  5. import Icon from './Icon';
  6. const wrapperStyle = {
  7. display: 'grid',
  8. placeItems: 'center',
  9. width: '100%',
  10. height: '100%',
  11. }
  12. const iconStyle = {
  13. width: '100rpx',
  14. height: '100rpx',
  15. margin: 'auto',
  16. display: 'block',
  17. }
  18. const txtStyle = {
  19. marginTop: '20rpx',
  20. textAlign: 'center',
  21. fontSize: '30rpx',
  22. color: '#202020',
  23. }
  24. export default (props) => {
  25. const { icon, text, link } = props;
  26. const onClick = () => {
  27. Taro.navigateTo({
  28. url: link
  29. })
  30. }
  31. return (
  32. <RatioView>
  33. <View style={wrapperStyle} onClick={onClick}>
  34. <View>
  35. <Icon name={icon} style={iconStyle} />
  36. <View style={txtStyle}>{text}</View>
  37. </View>
  38. </View>
  39. </RatioView>
  40. )
  41. }