category-icon.vue 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <template>
  2. <view class="category-icon" @click="handleClick">
  3. <view class="icon-wrapper" :style="{ backgroundColor: bgColor }">
  4. <image :src="icon" mode="aspectFit" class="icon-image"></image>
  5. </view>
  6. <text class="icon-text">{{ text }}</text>
  7. </view>
  8. </template>
  9. <script>
  10. export default {
  11. name: 'CategoryIcon',
  12. props: {
  13. icon: {
  14. type: String,
  15. required: true
  16. },
  17. text: {
  18. type: String,
  19. required: true
  20. },
  21. bgColor: {
  22. type: String,
  23. default: '#FF9500'
  24. }
  25. },
  26. methods: {
  27. handleClick() {
  28. this.$emit('click');
  29. }
  30. }
  31. };
  32. </script>
  33. <style lang="scss" scoped>
  34. .category-icon {
  35. display: flex;
  36. flex-direction: column;
  37. align-items: center;
  38. justify-content: center;
  39. .icon-wrapper {
  40. width: 100rpx;
  41. height: 100rpx;
  42. border-radius: 50%;
  43. display: flex;
  44. align-items: center;
  45. justify-content: center;
  46. margin-bottom: 12rpx;
  47. .icon-image {
  48. width: 56rpx;
  49. height: 56rpx;
  50. }
  51. }
  52. .icon-text {
  53. font-size: 24rpx;
  54. color: #333333;
  55. text-align: center;
  56. line-height: 1.2;
  57. }
  58. }
  59. </style>