2016-03-31 13 views
0

を定義していません。

ready(){ 
this.getJsonData(); 
}, 

methods: { 
getJsonData:() => { 
this.$http.get('url',{},{ 
    headers: { 
     "X-App-Token": "token" 
    } 
    }).then( (data) => this.$set('cdata',data.data)) 
    .catch((error) => console.log('Got a problem'+error)); 
}, 
}, 

エラー:

src\src\App.vue:23 Uncaught TypeError: Cannot read property '$http' of undefined 

//this becomes undefined. 

答えて

0

私は機能を生成するための矢印を使用するかもしれないと思います。その関数が定義されていないスコープにある可能性がありますか?試してみよう:

methods: { 
    getJsonData(){ 
    this.$http.get('url',{},{ 
     //...