封装个table

<template>
  <div class="table">
    <div class="thead">
      <div class="tr" style="padding-right: 10px;">
        <div class="td" v-for="col in columns" :key="col.key">{{ col.title }}</div>
      </div>
    </div>
    <div class="tbody" :style="{height: tableheight}" style="overflow-y: scroll;">
      <div class="tr" v-for="row in data" :key="row.key" style="margin-bottom: 10px;">
        <div class="td" v-for="col in columns" :key="col.key">{{ row[col.key]?row[col.key]:"-" }}</div>
      </div>
    </div>
  </div>
</template>
<script>
  export default {
    props: {
      columns: {
        type: Array,
        default () {
          return [];
        }
      },
      data: {
        type: Array,
        default () {
          return [];
        }
      },
      tableheight: {
            type: [String, Number],
            default: "500px",
        },
    }
  };
</script>
<style lang="less" scoped>
  ::-webkit-scrollbar {
  -webkit-appearance: none;
  width: 6px;
  height: 6px;
};
::-webkit-scrollbar-track {
  background: rgba(11,31,100,0.1);
  border-radius: 0;
};
::-webkit-scrollbar-thumb {
  cursor: pointer;
  background: rgb(2,124,233);
  transition: color 0.2s ease;
  border-radius: 15px;
};
  .table{
    width: 100%;
    padding: 5px;
    .thead{
      .tr{
        display: flex;
        justify-content: space-between;
        color: rgba(255,255,255,0.6);
        font-weight: 600;
        white-space: nowrap;
        .td{
          padding: 8px 16px;
          text-align: center;
          width: @td-width;
        }
        .td:nth-child(1){
            width: @td-1-width;
          }
        /* .td:nth-child(2){
          margin-right: 20px;
        } */
      }
    }
    .tbody{
        .tr{
          width: 100%;
          display: flex;
          background-color: rgba(8,32,85,1);
          .td{
            padding: 8px 16px;
            text-align: center;
            width: @td-width;
          }
          .td:nth-child(1){
            width: @td-1-width;
          }
          .td:nth-child(2){
            padding-right: 30px;
          }
          .td:nth-child(3){
            padding-right: 40px;
          }
          .td:nth-child(4){
            padding-right: 50px;
          }
          .td:nth-child(5){
            padding-right: 50px;
          }
        }
      }
  }
  
</style>

  • 5
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值