私は私のreadyメソッド
にこのコードを持っています:
this.$http.get('url',{},{
headers: {
"X-App-Token": "token"
}
}).then( (data) => this.$set('cdata',data.data))
.catch( (error) => console.log('Got a problem'+error));
問題は、これをメソッドオブジェクトの別の機能に移動すると機能しないことです。
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.