element-ui中表格 type="expand"设置全部展开
1、table需要绑定两个属性expand-row-key和row-key
<el-table :data="tableData" :expand-row-keys="expends" //expends是数组,设置你要展开行的id :row-key="getRowKeys" //通过getRowKeys方法获取到row的行id值 >
2、data中设置
data() { return { expends:[], } }
3、methods中设置
methods: { //设置table中的扩展项,展开的id,此处我需要全部展开 getExpends(){ var Id = this.tableData.map(item => item.id) this.expends = Id }, getRowKeys(row){ return row.id }, }
4、created()中调用 getExpends(),使一打开网页就全部展开
created() { this.getExpends(); },