el-table expands rows, @expand-change="expandChange" cannot appear for the first time, but the data appears for the second time

The main reason is that there is no corresponding array in the tableData data, and what you push in later is not real-time. Just modify the parameters inside after requesting from the back-end interface, and use map to add an empty array to it.

res.data.list.map(item => {
    
    
  item.expandList = []
})
this.tableData = res.data.list

Then assign the data requested in the expanded row into it

this.tableData.forEach(item => {
    
    
  if(item.id == row.id){
    
    
   item.expandList = res.data.detail
  }
})

Guess you like

Origin blog.csdn.net/weixin_44949068/article/details/128916369