info.vue 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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: 5px 0;
  38. color: rgba(255, 255, 255, 1);
  39. font-size: 14px;
  40. display: flex;
  41. word-break: break-all;
  42. span {
  43. flex: none;
  44. display: inline-block;
  45. width: 70px;
  46. text-align: right;
  47. height: 100%;
  48. margin-right: 20px;
  49. color: rgba(255, 255, 255, 0.7);
  50. }
  51. }
  52. }
  53. </style>