需求:表格展开行只展示一行(其实是为了避开另一个问题:展开多行数据,最后一次展开的数据 会覆盖之前展开行数据)
html:
{{scope.row.taskStartDate|formatDate}}-{{scope.row.taskEndDate|formatDate}}
{{scope.row.taskStartDate|formatDate}}-{{scope.row.taskEndDate|formatDate}}
js:展开一行行主通过table的expend-change事件实现
// 展开父表格数据 并查询该数据下的子数据
rowExpand(row, expandedRows) {
// 打印父任务内容
console.log(row)
let vm = this;
let params = {
taskId: row.id
};
getSearchSubTask(params).then(res => {
this.tableData2 = res.results;
});
//如果展开行数大于1
if(expandedRows.length>1){
expandedRows.shift();
}
},