After deleting a row of records in the table in vue, how to update the table (performance optimization)

In vue, we click the delete button to send a request to delete a row of records in the table. At this time, the database has been deleted, but the page has not been updated, so we often send a request to retrieve the form data, so that the page will be updated.
But if this method is used, two requests will be sent for each deletion, so we can not re-acquire the data after deletion, but delete a row in the original data, so that the data can also be updated

// 删除
async deleteCategory(index) {
    
    
let result = await deleteCategory({
    
    _id})
if(result.code === 200){
    
    
  // 不发请求更新页面	
  this.categoryList.splice(index, 1)
  this.$message.success(result.message)
}else{
    
    
  this.$message.error(result.message)
}
},

Guess you like

Origin blog.csdn.net/cocogogogo/article/details/124348306
Recommended