Vue封装组件-表格展示数据-LjTable1

效果图:

 使用:

<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>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值