Error in nextTick: “TypeError: Cannot read properties of undefined (reading ‘toggleRowSelection’)”
在使用elementUI里的带Checkbox表格时,想默认选中第一行,采组件库里的方法:
mounted() {
this.defaultChecked([this.nodesData[0]]);
},
methods: {
// 第一行默认选中
defaultChecked(rows) {
this.$nextTick(() => {
console.log(this.$refs.multipleTable);
this.nodesData.forEach(row => {
this.$refs.multipleTable.toggleRowSelection(row, true);
}
});
});
}
}
或者直接在mounted()里面写:
this.$refs.multipleTable.toggleRowSelection(this.nodesData[0], true);
都不能实现想要的效果,用了setTimeout延时调用还是不行,一直报toggleRowSelection未定义。