element中表格组件的row-class-name和class-name属性的使用以及无效处理

2024-01-21

1.这两个属性的使用,row-class-name用在el-table标签上,class-name用在el-table-column标签上。两个属性即可绑定类名也可绑定函数

<el-table :data="tableData" @selection-change="handleSelect" :row-class-name="shower" border  height="400px" scrollbar-always-on>
       <el-table-column width="60" type="selection" />
      <el-table-column width="150" prop="name" label="订单号" />
      <el-table-column width="120" prop="estimateTotal" label="跟单员" />
     <el-table-column width="5" />
    <el-table-column label="操作" width="150">
        <template #default="{ row }">
            <el-button type="primary" text @click="confirmData(row, 1)" v-if="true">确认应收数据</el-button>
            <el-button type="primary" text @click="Removeconfirm(row, 1)" v-else>撤销确认</el-button>
        </template>
    </el-table-column>
    <el-table-column width="180" prop="name" label="客户名称" class-name="unconfirmeds"/>
    <el-table-column width="120" prop="meetName" label="核销状态" />
</el-table>

2.绑定函数时就可以通过条件来决定哪行需要添加样式

function shower({row}){
    console.log(row);
    if(row.name==='阿尼亚'){
    return 'unconfirmeds'
    }else{
        return ''
    }
}

3.无效处理

样式没有效果的原因在于添加的样式不是全局样式,所以只需要将scoped去除或者自己定义一个全局样式

<style>
.unconfirmeds{
  background-color: rgba(255, 0, 0, 0.075) !important;
  color:red;
  font-weight: 700;
}
</style>

4.最终效果

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

element中表格组件的row-class-name和class-name属性的使用以及无效处理 的相关文章

随机推荐