根据这段代码写一个删除用户的方法updateContent(){ axios.post('http://localhost:8082/users/update',{ userId:this.changeTable.userId, userName:this.changeTable.userName, userSex:this.changeTable.userSex, userAccount:this.changeTable.userAccount, userPassword:this.changeTable.userPassword, userIdentity:this.changeTable.userIdentity, userIntroduction:this.changeTable.userIntroduction, userEmail:this.changeTable.userEmail, userPortrait:this.changeTable.userPortrait, }) .then(response=>{ this.$message.success("修改成功!") this.dialogFormVisible=false axios.get(`http://localhost:8082/users/${this.currentPage}/${this.pageSize}`) .then(response=>{ this.tableData=response.data.data.records this.total=response.data.data.total this.currentPage=response.data.data.current }).catch((error)=> { console.log(error); }) }).catch((error)=> { console.log(error) }) },
时间: 2024-01-26 19:05:06 浏览: 77
Error:in ./node-modules/axios/lib/platform/index.js
根据你提供的代码,我们需要编写一个删除用户的方法,可以参考以下代码:
```javascript
deleteUser() {
axios.delete(`http://localhost:8082/users/${this.changeTable.userId}`)
.then(response => {
this.$message.success("删除成功!")
this.dialogFormVisible = false
axios.get(`http://localhost:8082/users/${this.currentPage}/${this.pageSize}`)
.then(response => {
this.tableData = response.data.data.records
this.total = response.data.data.total
this.currentPage = response.data.data.current
}).catch((error) => {
console.log(error);
})
}).catch((error) => {
console.log(error)
})
},
```
这里我们使用了axios的delete方法,将要删除的用户的id作为参数传递给后端,删除成功后再重新获取用户列表进行渲染。在调用该方法时,需要保证this.changeTable.userId有值。
阅读全文