将数据(正文)附加到VueJS中的$ http.delete事件

ier*_*dna 6 vue.js vue-resource

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

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

在vue-resource 0.8.0中一切正常.升级到1.0.3后它没有.我在发行说明中发现他们body从GET请求中删除了,这是有道理的,但为什么DELETE请求停止工作?如果它们body在DELETE请求中禁用显式指定,我该如何添加它?

ier*_*dna 7

找到了解决方案.只需添加{body:data}到请求中:

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