
methods: {
checked() {
const that=this
console.log(that.goodsList)
that.$nextTick(() => {
for (let i = 0; i <that.goodsList.eList.length; i++) {
that.$refs.listPowerSupplyTab.toggleRowSelection(
that.goodsList.eList[i],
true
);
}
});
},
记得table 增加ref

效果图:

这篇博客详细介绍了如何在Vue.js应用中实现表格的全选功能。通过`$refs`引用表格组件并结合`$nextTick`方法,确保DOM更新后正确设置选中状态。博主提供了具体的代码示例,演示了如何遍历`goodsList.eList`并调用`toggleRowSelection`方法来选择表格中的每一行。
2266

被折叠的 条评论
为什么被折叠?



