index.vue 1.1 KB
<template>
  <div class="static-info">
    <div v-for="(item, index) in list"
         :key="index"
         class="static-item"
         :style="{ background: item.background }">
      <div class="label">
        {{ item.label }}
      </div>
      <div class="value">
        {{ data[item.key] }}
      </div>
    </div>
  </div>
</template>

<script>
export default {
	name: "StaticInfo",
	props: {
		list: {
			type: Array,
			default: () => [],
		},
		data: {
			type: Object,
			default: () => ({}),
		},
	},
};
</script>

<style lang="scss" scoped>
.static-info {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px; /* 增加一点间距 */
	padding: 8px 12px;
	.static-item {
		box-sizing: border-box;
		padding: 12px;
		flex: 1; /* 无论几个,都是平分剩余空间 */
		border-radius: 8px;
		font-size: 14px;
		color: #ffffff;
		min-width: 0; /* 防止内容过长撑破 flex 布局 */
		.label {
			margin-bottom: 5px;
			white-space: nowrap;
			overflow: hidden;
			text-overflow: ellipsis;
		}
		.value {
			font-size: 20px;
			font-family: "numberBold";
		}
	}
}
</style>