我正在使用新Laravel 5.4的Vue模板。在我的Office.vue我有這個代碼。Laravel 5.4和Vue 2.0.1無法讀取未定義的屬性'get'
<template>
<div class="container">
<div class="row">
<div class="col-md-8 col-md-offset-2">
<div class="panel panel-default">
<div class="panel-heading">Example Component</div>
<div class="panel-body">
I'm an example component! {{ message}} | {{ type}} | {{ number }}
</div>
<span id="vue"></span>
</div>
</div>
</div>
</div>
</template>
<script>
export default {
mounted() {
return this.displayOffices();
},
data: function(){
return {
message: "aw",
type: "test",
number: 2
}
},
methods: {
displayOffices: function(){
this.$http.get('/vueOffice', function(course) {
console.log(course);
});
}
}
}
</script>
顯示的數據是好的,很好的工作,但我得到的錯誤與
Uncaught TypeError: Cannot read property 'get' of undefined
這是此。$ http.get
我試圖做到的是從返回JSON數據的路線獲取數據。
我需要幫助解決這個錯誤,一直試圖尋找答案,但每個人都用不同的方式來實現Vuejs。
如果您正在使用'axios'而不是'vue-resource'然後r使用'axios'放置'this。$ http'。 – mrabbani
您好我可以標記該所接受,感謝 – Ikong