vue el-table反显

1.当返回值与列表值相同时

toggleSelection(rows) {
        if (rows) {
          rows.forEach(row => {
            this.$refs.multipleTable.toggleRowSelection(row);
          });
            console.log(this.$refs.multipleTable);
        } else {
          this.$refs.multipleTable.clearSelection();
        }
      },

 getlist(){
      //row为数组
  this.tableData:=[{
          date: '2016-05-03',
          name: '王小虎',
          address: '上海市普陀区金沙江路 1518 弄'
        }, {
          date: '2016-05-02',
          name: '王小虎',
          address: '上海市普陀区金沙江路 1518 弄'
        }, {
          date: '2016-05-04',
          name: '王小虎',
          address: '上海市普陀区金沙江路 1518 弄'
        },
    ]

         this.toggleSelection(row,true)
}

2.当返回值与列表不相同时

    getlist(){
          var listData = [
            {id:"1234",name:"bob"},
            {id:"2451",name:"mary"},
            {id:"6666",name:"tom"},
            {id:"5675",name:"jerry"},
            {id:"8421",name:"ken"},
        
        ]
        let index = listData.findIndex( item => item.id == '8421');
         this.toggleSelection([this.listData[index]],true)
     },

     toggleSelection(rows) {
        if (rows) {
          rows.forEach(row => {
            this.$refs.multipleTable.toggleRowSelection(row);
          });
           
        } else {
          this.$refs.multipleTable.clearSelection();
        }
      },

你可能感兴趣的:(vue.js,javascript,前端)