【问题标题】:Attaching data (body) to $http.delete event in VueJS将数据(正文)附加到 VueJS 中的 $http.delete 事件
【发布时间】:2017-02-16 10:26:37
【问题描述】:

我的 Vue.JS 组件中有以下方法:

removeItems (itemsArray) {
    this.$http.delete(this.apiUrl, {items : itemsArray})
    .then((response) => {
       this.msg = response.msg;
    });
}

在 vue-resource 0.8.0 中一切正常。升级到 1.0.3 后就没有了。我在发行说明中发现他们从 GET 请求中删除了body,这很有意义,但为什么 DELETE 请求停止工作? 如果他们禁止在 DELETE 请求中明确指定 body,我该如何添加它?

【问题讨论】:

    标签: vue.js vue-resource


    【解决方案1】:

    找到了解决办法。只需在请求中添加{body:data}

    removeItems (itemsArray) {
      this.$http.delete(this.apiUrl, {body: {items : itemsArray}})
      .then((response) => {
        this.msg = response.msg;
      });
    }
    

    【讨论】:

      猜你喜欢
      • 2014-07-27
      • 2012-05-22
      • 1970-01-01
      • 1970-01-01
      • 2022-08-14
      • 2018-10-19
      • 2021-07-21
      相关资源
      最近更新 更多