美文网首页
使用element-ui写列表,实现:改变选

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

作者: 小北呀_ | 来源:发表于2019-10-29 19:56 被阅读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>
根据个人需求自己修改就可以成功了。

相关文章

网友评论

      本文标题:使用element-ui写列表,实现:改变选

      本文链接:https://www.haomeiwen.com/subject/shygvctx.html