错误示范:
1.直接setCurrentRow失败(this.currentRow是之前保存的表格当前选中行的数据)
this.$refs.table.setCurrentRow(this.currentRow);
2.以为是表格没生成就执行了setCurrentRow导致设置不成功,所以使用了this.$nextTick,依旧失败
this.$nextTick(() => {
this.$refs.table.setCurrentRow(this.currentRow);
});
最后解决:
好吧,最后发现问题出在setCurrentRow的参数上,不管你有没有改动表格数据,用你需要选中的行id,去遍历表格数据,遍历到item.id===id,则row =item,最后用this.$refs.table.setCurrentRow(row)可以解决。
完整代码如下:
this.$nextTick(() => {
let currentRow = this.tableData.filter(item => {
return item.id === this.currentRowId;
});
console.log("有选中行", currentRow[0]);
this.$refs.table.setCurrentRow(currentRow[0]);
});
这个nextTick因为写了就没去掉,不包可能也行吧。
这是之前参数的由来:

参考:







![[Mac软件]Downie 4.6.34视频下载工具](https://img-blog.csdnimg.cn/img_convert/4a692c7609555f4b27b85ac001c12e8e.png)









![竞赛 题目:基于深度学习的图像风格迁移 - [ 卷积神经网络 机器视觉 ]](https://img-blog.csdnimg.cn/b72d9a37c238426c81819f44f6a73419.png?x-oss-process=image/watermark,type_ZHJvaWRzYW5zZmFsbGJhY2s,shadow_50,text_Q1NETiBARGFuQ2hlbmctc3R1ZGlv,size_16,color_FFFFFF,t_70,g_se,x_16)


