info.vue 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <template>
  2. <div class="info" v-if="data">
  3. <h2>{{ title }}</h2>
  4. <div>
  5. <p v-for="(label, key) in labelMap">
  6. <span>{{ typeof label === "string" ? label : label[0] }}:</span>
  7. {{ typeof label === "string" ? data[key] : label[1](data[key]) }}
  8. </p>
  9. </div>
  10. </div>
  11. </template>
  12. <script setup lang="ts">
  13. defineProps<{
  14. title: string;
  15. data: Record<string, any>;
  16. labelMap: Record<string, string | [string, (v: any) => any]>;
  17. }>();
  18. </script>
  19. <style lang="scss" scoped>
  20. .info {
  21. margin-bottom: 30px;
  22. h2 {
  23. display: flex;
  24. justify-content: space-between;
  25. align-items: center;
  26. margin-bottom: 10px;
  27. font-size: 16px;
  28. }
  29. > div {
  30. display: flex;
  31. flex-wrap: wrap;
  32. p {
  33. width: 33.33%;
  34. }
  35. }
  36. p {
  37. margin: 10px 0;
  38. padding: 0 20px;
  39. color: rgba(255, 255, 255, 1);
  40. font-size: 14px;
  41. display: flex;
  42. word-break: break-all;
  43. span {
  44. flex: none;
  45. display: inline-block;
  46. width: 70px;
  47. text-align: right;
  48. height: 100%;
  49. margin-right: 10px;
  50. color: rgba(255, 255, 255, 0.7);
  51. }
  52. }
  53. }
  54. </style>