2016-08-05 3 views
0

laravel (5.2)과 vue에 새로운 기능을 사용하고있다. 데이터베이스에서 뷰에 데이터를 전달하려고합니다. 내 오른쪽 경로가 정상적으로 보이고 일부 json 데이터 응답이 표시되지만 콘솔이나 내보기에 데이터를 기록하는 데 문제가 있습니다. 친절하게 내가 잘못하고있는 것을 알려주십시오. 여기

내 ShowEvent 구성 요소는 내 main.js는

import Vue from 'vue'; 
import VueResource from 'vue-resource'; 
Vue.use(VueResource); 
import ShowEvent from './components/ShowEvent.vue'; 



new Vue({ 

el: '#app', 

components: {ShowEvent: ShowEvent}, 

ready(){ 


     alert("Ready to go!, Show Events"); 


} 

}); 

을 제기하는 .vue 파일을 여기에

<template> 

<div class="events_list"> 
    <h1> My Events </h1> 

    <ul class="list-group"> 

     <li class="list-group-item" v-for="event in list"> 
      {{ event.body}} 

     </li> 

    </ul> 
</div> 

</template> 

<script> 
export default { 


    data: function() { 
     return { 


      list: [] 

     }; 

    }, 

    created: function(){ 

     this.fetchEventsList(); 



    }, 

    methods: { 
     fetchEventsList: function() { 
      this.$http.get('/api/events', function(data){ 

       console.log(data); 

      }); 

     }, 

     delete: function(event) { 
      this.list.$remove(event); 

     } 
    } 


} 

에 저장됩니다 그리고 이것은 뷰 파일

입니다
<!DOCTYPE html> 
<html> 

<head> 
<title>Eventer</title> 
</head> 


<body> 

<div id="app" class="container"> 

<show-event> 

</show-event> 

</div> 


<script src="/js/main.js"></script> 

</body> 

</html> 
+0

귀하의 요청에 실패 콜백을 추가, 당신은 모든 또한 요청 – gurghet

+0

, 당신은 VUE-자원의 버전입니다 동안 잘 작동한다고 가정하지 말아야 사용중인 구문이 현재 버전이 잘못되었습니다 – gurghet

+0

vue 1.0.26 및 vue-resource 0.9.3 – Mover

답변

2

Replac 전자 전화로 자세한 정보를 원하시면

this.$http.get('/api/events').then((response) => { 
    console.log(response.data) 
}, (error) => { 
    console.log(error) 
}) 

Check the docs

+0

Works를 사용하고 있습니다. 감사합니다 – Mover