recently, I have been making a table for the background management system, asking to expand the realistic details, encountered strange problems (doubts from the back-end dog), completed a test code, and sent a
problem description (see code)
- hide-> expand: the following two properties do not cause the web page to respond
- other column expansion-> Toggle current column expansion: these two properties can take effect again
<template>
<el-table
:data="tableData5"
style="width: 100%"
@expand-change="expandChange">
<el-table-column label=" ID"prop="id"></el-table-column>
<el-table-column label="" prop="name"></el-table-column>
<el-table-column label="" prop="desc"></el-table-column>
<el-table-column type="expand">
<template >
<el-table v-loading="loading" :data="subTableData">
<el-table-column label="" prop="shop"></el-table-column>
<el-table-column label=" ID" prop="shopId"></el-table-column>
<el-table-column label="" prop="category"></el-table-column>
<el-table-column label="" prop="address"></el-table-column>
</el-table>
</template>
</el-table-column>
</el-table>
</template>
<script>
import axios from "axios"
var Mock = require("mockjs");
Mock.mock("/subtable/data",[{
category: "",
address: "",
shop: "",
shopId: "10333"
}
])
export default {
data() {
return {
loading:true,
subTableData:[],
tableData5: [{
id: "12987122",
name: "",
desc: "",
}, {
id: "12987123",
name: "",
desc: "",
}, {
id: "12987125",
name: "",
desc: "",
}]
}
},
methods: {
expandChange(row, expandedRows) {
let _this = this
//
_this.loading = true
_this.subTableData = []
//
axios.get("/subtable/data")
.then(function (res) {
/**
* --------
* 1.->:
* 2.->:
*/
_this.subTableData = res.data
_this.loading = false
}).catch(function (error) {
console.log(error);
});
if (expandedRows.length > 1) {
//
expandedRows.shift()
}
}
}
}
</script>