//让 act 为 1 的默认选中
<template>
<el-table ref="table" :data="list">
<el-table-column type="selection"></el-table-column>
<el-table-column label="name" prop="name"></el-table-column>
<el-table-column label="attribute" prop="attribute"></el-table-column>
</el-table>
</template>
<script>
export default{
data(){
return{
list:[
{act:1,name:'豆浆',attribute:'喝的'},
{act:1,name:'油条',attribute:'吃的'},
{act:0,name:'粥',attribute:'喝的'},
{act:0,name:'煎堆',attribute:'吃的'},
]
}
},
mounted(){
this.$nextTick(()=>{
this.list.forEach(item=>{
if(item.act){
this.$refs.table.toggleRowSelection(item)
}
})
})
}
}
</script>
element el-table 多选默认选中
最新推荐文章于 2024-05-16 12:05:18 发布