1.首先在el-table中加上 ref=“defaultSelectMenu”,在data中声明该数组 defaultSelectMenu: [];defaultSelectMenu是自定义的数组名称
2.运用el-table的toggleRowSelection的属性完成默认选中。
我这里用了this.$nextTick,主要作用是回调延迟到下次 DOM 更新循环之后执行,可以在回调中获取更新后的DOM
this.$nextTick(function () {
response.forEach(row => {
this.$refs.defaultSelectMenu.toggleRowSelection(row);
});
})