slot插槽及Element-ui 中<template slot-scope=“scope“>

<el-table-column label="状态" align="center" prop="state">
        <template scope="scope">
          <div :style="{'color':scope.row.state==0? 'red':scope.row.state==1? 'orange':scope.row.state==2? 'green':'#333'}">
            {{scope.row.state|stateTrans}}
          </div>
        </template>
      </el-table-column>

slot-scope=“scope” //取到当前单元格
scope.$index //拿到当前行的index
scope.row //拿到当前行的数据对象
scope.row.date //是对象里面的data属性的值

那么对于每一个el-table-column,我们只需要使用prop="date",就可以将该列的数据绑定为该数组所有的对象中的“date”属性,我们可以理解为对于tableData,这里始终取的是tableData[$index].date

table按照tableData这个数组的长度来生成多少行,按照有多少个el-table-column来生成多少列。

slot插槽

插槽有三种:默认插槽、具名插槽、作用域插槽。

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值