axios 请求体里,为什么没有参数

发布于 2022-09-12 03:07:35 字数 493 浏览 7 评论 0

我写的有问题么?在线等

  import axios from 'axios'
  axios({
    method: 'get',
    url: "http://192.168.4.206:8858/purchase/listAll", // 测试
    data: {
      start: this.search.date[0],
      end: this.search.date[1],
      amountMin: this.search.money1,
      amountMax: this.search.money2,
      txt: this.search.key,
    }
  }).then(res => {
    console.log(res.data)
  }).catch(error => {
  });

image.png

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

夏天碎花小短裙 2022-09-19 03:07:35

get方法,本身就没有data选项的。data选项表示请求体。
你的get请求应该使用config里的params进行参数拼接。

axios({
  method: 'get',
  // ...
  config: {
    params: {
        start: this.search.date[0],
        // ...
    }
  }
})
人生百味 2022-09-19 03:07:35
data: Qs.stringify({
    start: this.search.date[0],
    end: this.search.date[1],
    amountMin: this.search.money1,
    amountMax: this.search.money2,
    txt: this.search.key,
})
执笔绘流年 2022-09-19 03:07:35

楼上的解释就很明确了

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文