使用element-ui写列表,实现:改变选

2019-10-29  本文已影响0人  小北呀_

Element-ui 文档上写:


1 2

template代码:

   <el-table
      :row-class-name="rowClassName"
      :data="list"
      @selection-change="selectionChange"
    >
。。。。

selectionChange函数是要把选中的列表保存住,

rowClassName函数就是根据选中的索引来添加className

  methods:{
    selectionChange(val) {
    //  val是列表选中的数组信息
      this.selectionList = val
    },
    rowClassName() {
      //下面的意思就是列表索引为0的这行加一个className:warning-row,
      if (rowIndex === 0) {
        return 'warning-row';
      }
    }
  },
<style>
.warning-row{
  background: pink!important;
}
</style>

样式不能写在<style scoped>这里面,需要是<style>
根据个人需求自己修改就可以成功了。

上一篇 下一篇

猜你喜欢

热点阅读