html table
<el-table :stripe="true" style="width: 100%" border highlight-current-row
ref="table"
:data="tableData"
row-key="id">
</el-table>
PS:注意 ref=“table” 配置 不加这个在vue中会找不到这个组件
vue
//为了防止指向错误 所以我都是直接提出来的
let self=this;
$.each(vm.tableData, function (index, item) {
//这里可以用你的条件
if (item.state == "0") {
//默认选中
self.$nextTick(function () {
self.$refs.table.toggleRowSelection(item, true);
})
}
})
如果有更好的解决办法 请留言
本文介绍如何在Vue框架中使用Element UI的El-Table组件,并实现表格数据行的预选中功能。通过设置ref属性和利用$nextTick方法,可以实现在页面加载时根据特定条件自动选中表格中的某一行。
1万+

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



