DataCard.vue 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <template>
  2. <view class="data-card-container">
  3. <view class="card-grid">
  4. <view v-for="(item, index) in cardData" :key="index" class="card-item">
  5. <view class="card-content">
  6. <!-- 左侧内容 -->
  7. <view class="left-content">
  8. <view class="label">{{ item.label }}</view>
  9. <view class="value">{{ item.value }}</view>
  10. </view>
  11. <!-- 右侧图片 -->
  12. <view class="right-content">
  13. <image :src="item.image" class="card-image" mode="aspectFit" />
  14. </view>
  15. </view>
  16. </view>
  17. </view>
  18. </view>
  19. </template>
  20. <script>
  21. export default {
  22. name: 'DataCard',
  23. props: {
  24. // 卡片数据数组
  25. cardData: {
  26. type: Array,
  27. default: () => []
  28. }
  29. },
  30. data() {
  31. return {
  32. // 示例数据
  33. }
  34. },
  35. computed: {
  36. }
  37. }
  38. </script>
  39. <style lang="scss" scoped>
  40. .data-card-container {
  41. padding: 24rpx 0;
  42. }
  43. .card-grid {
  44. display: grid;
  45. grid-template-columns: repeat(2, 1fr) !important; // 每行两个等宽列
  46. gap: 24rpx;
  47. .card-item {
  48. min-width: 0;
  49. box-sizing: border-box;
  50. .card-content {
  51. background: #fff;
  52. border-radius: 16rpx;
  53. padding: 32rpx 24rpx;
  54. box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.1);
  55. display: flex;
  56. align-items: center;
  57. justify-content: space-between;
  58. height: 160rpx;
  59. .left-content {
  60. flex: 1;
  61. display: flex;
  62. flex-direction: column;
  63. justify-content: center;
  64. .label {
  65. font-size: 24rpx;
  66. color: #666;
  67. margin-bottom: 8rpx;
  68. font-weight: 400;
  69. }
  70. .value {
  71. font-size: 45rpx;
  72. color: #333;
  73. font-weight: bold;
  74. line-height: 1.2;
  75. }
  76. }
  77. .right-content {
  78. flex-shrink: 0;
  79. margin-left: 24rpx;
  80. .card-image {
  81. width: 80rpx;
  82. height: 80rpx;
  83. border-radius: 8rpx;
  84. }
  85. }
  86. }
  87. }
  88. }
  89. // 响应式适配
  90. @media (max-width: 750px) {
  91. .card-grid {
  92. grid-template-columns: 1fr; // 小屏幕下每行一个
  93. }
  94. }
  95. </style>