Laravel 5 Vue.js-此.$http.get不起作用

Laravel 5 Vue.js-此.$http.get不起作用,laravel-5,vuejs2,vue-resource,Laravel 5,Vuejs2,Vue Resource,我正在用Vue js在拉雷维尔开发项目 下面是我的代码,当我使用this.$http.get方法时 Vue resource js我没有得到任何东西,但如果我使用$。getJSON 方法我正在从数据库中获取所有记录 brand.blade.php @section('content') <div class="container"> <brands></brands> </div> <template

我正在用Vue js在拉雷维尔开发项目

下面是我的代码,当我使用this.$http.get方法时 Vue resource js我没有得到任何东西,但如果我使用$。getJSON 方法我正在从数据库中获取所有记录

brand.blade.php

@section('content')

<div class="container">

        <brands></brands>

    </div>

    <template id="brand-template">

        <ul>

            <li v-for="brand in list.brand"> @{{ brand }}  </li>

        </ul>

    </template>

@endsection

@push('scripts')
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="https://unpkg.com/vue/dist/vue.js"></script>
<script src="https://cdn.jsdelivr.net/vue.resource/1.0.3/vue-resource.min.js"></script>
<script src = "public/js/brand.js"></script>
@endpush
谁能告诉我发生了什么我搞不清楚。

VueResource返回一个对象。尝试使用
.body

var-app=新的Vue({
el:“#应用程序”,
数据:{
员额:[]
},
挂载:函数(){
var vm=这个
这是。$http.get('https://jsonplaceholder.typicode.com/posts')
.然后(功能(响应){
vm.posts=response.body
})
}
})
[v-clope]{
显示:无;
}

  • {{post.title}}

您的意思是这样的:this.$http.get('api/brands',function(brand){this.list=brand.body;}.bind(this));你能在这里发布这个问题的代码吗?这样我就可以更好地理解这个问题,将来其他开发者也可以知道发生了什么。我在这行中遇到了错误。然后(response=>/(here get error)this.list=response.body)@djones谢谢它的工作。我还使用mzabriskie/axios软件包进行了测试。我觉得我更适合axios。顺便说一下,谢谢。您能告诉我们如何设置vue吗?您是否确实添加了vue资源?这是未定义的.http还是响应?
Vue.component('brands',{

template: '#brand-template',

data: function(){

    return{

        list: []
    }

},

created: function(){

    this.$http.get('api/brands', function(brand){
    // if I use $.getJSON then it'e working perfect and I'm getting all the records
      this.list = brand;

    }.bind(this));

}

});

new Vue({

el: '.container'


})