默认勾选失效问题
注意要当数据都加载完的时候 再去 勾选 使用this.$nextTick即可
<el-table ref="multipleTable" :data="tableData" style="width: 100%" selection-change="tableSelectChange">
<el-table-column
type="selection"
width="55">
</el-table-column>
<el-table-column
label="名称"
width="120">
<template slot-scope="scope">{{ scope.row.detailName }}</template>
</el-table-column>
<el-table-column
label="单价(元)"
width="120">
<template slot-scope="scope">{{ scope.row.money }}</template>
</el-table-column>
</el-table>
默认选一行
this.$nextTick(function () {
this.$refs.multipleTable.toggleRowSelection(this.tableData[this.tableData.length-1],true);
});
});
默认全选
this.$nextTick(function () {
this.tableData.forEach(row => {
this.$refs.multipleTable.toggleRowSelection(row,true);
});
});