-2
我使用laravel 5.4作为后端,并使用Vue.js作为前端。我将使用Vue将值传递给Controller并存储数据。但是,当我检查控制台,响应显示错误
自动填充
$HTTP_RAW_POST_DATA
已取消,将 在未来的版本中删除。
我使用的服务器是WAMPServer 3.0.6。 我发现解决方案正在改变php.ini,$HTTP_RAW_POST_DATA=-1
,但仍然有错误。
那么还有其他解决方案吗?
这是我的Vue公司代码
<script>
export default {
mounted(){
},
data() {
return {
content :'',
not_working: true
}
},
methods:{
create_post() {
this.$http.post('/create/post', { content:this.content })
.then((resp)=> {
this.content = ''
noty({
type: 'success',
layout: 'bottomRight',
text: 'Your post has been posted.'
});
console.log(resp)
})
}
},
watch :{
content(){
if(this.content.length > 0)
this.not_working = false
else
this.not_working= true
}
}
}
我的控制器
public function store(Request $request){
return Post::create([
'body' => $request->content,
'user_id' => Auth::id()
]);
}
更新: 后,我从互联网研究,似乎是解决了问题,但发生了新的问题,这是
TokenMismatchException
我包括了<meta name="csrf-token" content="{{ csrf_token() }}">
但仍然有这个错误,我现在该怎么办?
首先 - 你使用的是Axios还是vue-resource? –
我仍然使用vue-resource ... – masterhunter
用axios来代替它 –