解决el-table 多选下一页消失的问题

2020-09-04  本文已影响0人  阿克兰
  <el-table   ref="multipleTable"
                  :data="patentList"   :row-key="getRowKey"  @selection-change="handleSelectionChange">  // :row-key="getRowKey"  加一下这个
                  <el-table-column type="selection" width="55" :reserve-selection="true"></el-table-column>  //reserve-selection="true"  这个得加一下
                  ......

 </el-table>
  watch: {
// 监听数据变化时候,改变选择
     patentList(val){
         val.forEach((item,i)=>{
              this.multipleSelection.forEach((multItem,j)=>{
                  if(item.id==multItem.id){
                      this.$refs.multipleTable.toggleRowSelection(item,true);//这步操作是让  页面显示选中的数据
                  }
              })
          })
     }

  },
methods:{
    getRowKey:function(row){
         return row.id
      },
 handleSelectionChange(val) {
      this.multipleSelection = val;
      console.log(this.multipleSelection )
    },


}
上一篇 下一篇

猜你喜欢

热点阅读