按照您的教程用的和您一样的vuejs版本,完美运行!但是我将vue-resource版本换成1.0后chorm中出现
vue.js:1023 [Vue warn]: Error when evaluating expression "task.body": TypeError: Cannot read property 'body' of undefined (found in component: <task-app>)
我刚才google找到答案了,原来没有把路由放到web下面,可是居然回报token的错误!
<meta id="token" name="token" value="{csrf_token()}">
Vue.http.headers.common['X-CSRF-TOKEN'] = document.querySelector('#token').getAttribute('value');
TokenMismatchException in VerifyCsrfToken.php line 67:
在<head>和<script>中加了token的语句,依旧如此。可是之前的blog中我用这些是正常的,真奇怪.
知道用markdown排版了
this.$http.get('api/task').then((response) => {
that.list=response.data;
}, (response) => {
alert('error!');
});
用这种官方的方式就可以了
this.$http.get('api/task',(function(data){
that.list=data;
});
返回的data是空值 啊
现在的版本必须这样写才会在callback里面执行push函数:
this.$http.post('{url("/comment")}', post).then(function(){
this.comments.push(comment);
});