2017-04-04 81 views
1

大家好大家POST和GET方法正在我的应用程序上工作,但PATCH方法没有。在我的WAMP服务器上一切正常。在VPS服务器上 - 不要。我得到405方法不允许。Vue.js PATCH方法不允许

我使用:Laravel 5.4,Vue.js 2.

修补方法:

axios.patch('/profile/' + this.profile.id + '/update', this.overview) 
.then(resp => { 
    this.successDataSave(resp.data) 
}) 

路线:

Route::patch('/profile/{profile}/update', '[email protected]'); 

编辑:PATCH只在爱可信方法不起作用,如果我在html表单上使用修补程序路由,{{method_field('PATCH')}}它工作。

+0

看到CORS预检要求:http://stackoverflow.com/questions/42137354/axios-call-api-with-get-become-options/42141696#42141696 – SLYcee

回答

2

使用{{ method_field('PATCH') }}生成以下HTML: <input type="hidden" name="_method" value="PUT">

所以试试套:this.overview._method = "PUT"

然后做一个帖子:

axios.post('/profile/' + this.profile.id + '/update', this.overview) 
    .then(resp => { 
     this.successDataSave(resp.data) 
})