自定义 竖向表格

效果图:

在这里插入图片描述

代码:
<template>
  <div class="mesTable">
    <div class="table">
      <div
        class="tr"
        v-for="(item, index) in tableData"
        :key="index"
        :class="[item.line ? 'one' : 'two']"
      >
        <div class="th" :class="{ nodata: !item.value }">
          <span>{{ item.title }}</span>
        </div>
        <div class="td" :class="{ nodata: !item.value }">
          <img
            v-if="item.isIcon && item.value != '--'"
            width="52"
            :src="item.value"
          />
          <a
            v-else-if="item.isUrl && item.value != '--'"
            :href="item.value"
            target="_blank"
            >{{ item.value }}</a
          >
          <p v-else>{{ item.value }}</p>
        </div>
      </div>
      <Loading v-if="isLoading"></Loading>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    tableData: {
      type: Array,
      default: () => [
        {
          title: "",
          value: "",
          line: "",
          isUrl: false,
          isIcon: false,
        },
      ],
    },
  },
  data() {
    return {
      isLoading: false,
    };
  },
  watch: {
    tableData: {
      handler(val) {
        if (val.length) {
          this.isLoading = false;
        } else {
          this.isLoading = true;
        }
      },
      deep: true,
    },
  },
  mounted() {},
  methods: {},
};
</script>

<style lang="less" scoped>
.mesTable {
  background: #fff;
  .table {
    border: 1px solid #dee9ff;
    display: flex;
    flex-wrap: wrap;
    font-size: 14px;
    font-family: MicrosoftYaHeiUI;
    .tr {
      display: flex;
      // flex-wrap: wrap;
      align-items: center;
      font-size: 14px;
      line-height: 20px;
      background: rgba(84, 174, 255, 0.1);

      &.one {
        width: 100%;
      }
      &.two {
        width: 50%;
      }
      &:not(:last-child) {
        border-bottom: 1px solid #dee9ff;
      }
      .one {
        width: 100%;
        display: flex;
        align-items: center;
      }
      .two {
        width: 50%;
        display: flex;
        align-items: center;
      }
      .th {
        width: 210px;
        color: #677380;
        display: flex;
        align-items: center;
        padding: 12px 0 12px 20px;
        height: 100%;
        word-break: break-all;
        &:not(:last-child) {
          border-right: 1px solid #dee9ff;
        }
      }
      .nodata {
        height: 48px;
      }
      .td {
        display: flex;
        align-items: center;
        height: 100%;
        background: #fff;
        padding: 12px 20px 12px 20px;
        flex: 1;
        color: #333333;
        word-break: break-all;
        a {
          color: #1492ff;
        }
        &:not(:last-child) {
          border-right: 1px solid #dee9ff;
        }
      }
    }
  }
}
</style>
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值