关于使用axios的delete请求,请求可以看到参数,但是后台接收到的是null的解决方法

阅读 118

2022-02-06

关于使用axios的delete请求,请求可以看到参数,但是后台接收到的是null的解决方法

后台拿不到参数的写法

this.$http.delete("http://localhost:8989/vue/user/delete", {data: {id:id}}).then(res => {
        if (res.data.success) {
          alert("点击确认刷新页面?");
          this.findAll();
        }
      })

后台拿到参数的写法

在这里插入代码片this.$http.delete("http://localhost:8989/vue/user/delete", {params: {id:id}}).then(res => {
        if (res.data.success) {
          alert("点击确认刷新页面?");
          this.findAll();
        }
      })

重点: 只需要把config里面的data换成params即可

精彩评论(0)

0 0 举报