<el-button
type="primary"
icon="el-icon-delete"
size="mini"
@click="removeDaleiByCode(scope.row.Code)"
></el-button>
removeDalei:{
Code:''
}
async removeDaleiByCode(Code) {
this.removeCode = Code
// console.log(Code)
// 弹窗询问是否删除
const confirmResult = await this.$confirm(
'此操作将永久删除该农产品大类, 是否继续?',
'提示',
{
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
}
).catch((err) => err)
// 如果用户确认删除,则返回值为字符串 confirm
// 如果用户取消删除,则返回值为字符串 cancel
// console.log(confirmResult)
if (confirmResult !== 'confirm') {
return this.$message.info('已取消删除')
}
this.removeDalei.Code=Code
console.log(this.removeDalei);
const {data:res} = await this.$http.delete(
this.hd + 'productMainCategory',
this.removeDalei
)
if(res.code!== 200){
return this.$message.error('删除失败,此大类已经被引用')
}
this.$message.success('删除成功')
this.getDaLeiList()
},
DELETE http://1.117.241.132:8080/sy/productMainCategory 400
[Vue warn]: Error in v-on handler (Promise/async): "Error: Request failed with status code 400"
found in
---> <ElButton> at packages/button/src/button.vue
<ElTooltip>
<ElTableBody>
<ElTable> at packages/table/src/table.vue
<ElCard> at packages/card/src/main.vue
<MaintenanceOfAgriculturalProducts> at src/components/submenu/MaintenanceOfAgriculturalProducts.vue
<ElMain> at packages/main/src/main.vue
<ElContainer> at packages/container/src/main.vue... (1 recursive calls)
<Home> at src/components/Home.vue
<App> at src/App.vue
<Root>
vue.runtime.esm.js?2b0e:1888 Error: Request failed with status code 400
报错原因:前端请求的字段名称或者字段类型和后台编写的实体类不一样,或者前端提交的参数和后台需要的参数个数不匹配,导致无法封装,报错400
打开控制台,看下 network,一般后端会返回具体哪个字段不对 或者缺失
参数 传的不对吧
确认传递的参数,参数类型是否正确