效果图:
使用:
<template>
<div>
<LjTable1
:tableData="tableData"
labelColor="#1DCBF3"
valueColor="white"
borderColor="#1DCBF3"
></LjTable1>
</div>
</template>
<script>
import LjTable1 from "@/components/LjTable1/index.vue";
export default {
components: {
LjTable1,
},
data() {
return {
properties: {
name: "标题",
area: "",
circumference: 100,
treeType: "桃树",
treeNumber: 50,
soilType: "xxx",
harvest: 100,
estimatedOutputValue: 100,
growthValue: 100,
economicBenefits: 100,
status: true,
note: "",
},
};
},
computed: {
tableData() {
return [
{
label: "面积",
value: this.properties.area,
},
{
label: "周长",
value: this.properties.circumference,
},
{
label: "果树品种",
value: this.properties.treeType,
},
{
label: "果树数量",
value: this.properties.treeNumber,
},
{
label: "土壤类型",
value: this.properties.soilType,
},
{
label: "产量",
value: this.properties.harvest,
},
{
label: "预估产值",
value: this.properties.estimatedOutputValue,
},
{
label: "长势值",
value: this.properties.growthValue,
},
{
label: "经济效益",
value: this.properties.economicBenefits,
},
{
label: "状态",
value: this.properties.status,
},
];
},
},
};
</script>
LjTabel1:
<!--LjTable1-->
<template>
<div class="LjTable1">
<p
v-for="(item, index) in tableData"
:key="index"
:style="{
borderColor: borderColor,
}"
>
<span :style="{ color: labelColor }">{{ item.label }}</span
>:<strong :style="{ color: valueColor }" style="float: right">{{
item.value
}}</strong>
</p>
</div>
</template>
<script>
export default {
name: "LjTable1",
components: {},
props: {
tableData: {
type: Array,
default: () => [],
},
borderColor: {
type: String,
default: "white",
},
labelColor: {
type: String,
default: "#1dcbf3",
},
valueColor: {
type: String,
default: "white",
},
},
data() {
return {};
},
computed: {},
created() {},
mounted() {},
filters: {},
methods: {},
watch: {},
};
</script>
<style lang="scss" scoped>
.LjTable1 {
display: grid;
grid-template-columns: repeat(3, 1fr);
p {
border-width: 1px;
border-style: solid;
line-height: 40px;
padding: 0 7px;
}
}
</style>