Vue.js 未捕获(承诺中)TypeError:无法读取未定义的属性“data”
我对VueJS Laravel有这个问题 这是我的家Vue.js 未捕获(承诺中)TypeError:无法读取未定义的属性“data”,vue.js,vuejs2,Vue.js,Vuejs2,我对VueJS Laravel有这个问题 这是我的家 <template> <table> <tr v-for="models in model.data"> {{models.nom}} </tr> </table> </template> <script> import axios from 'axios' export default{
<template>
<table>
<tr v-for="models in model.data">
{{models.nom}}
</tr>
</table>
</template>
<script>
import axios from 'axios'
export default{
data() {
return {
model: {}
}
},
created:function(){
this.fetchDataResto()
},
methods: {
fetchDataResto(){
var vm = this
axios.get('/test')
.then(function response(){
Vue.set(vm.$data, 'model', response.model.data)
})
}
}
}
</script>
在promise TypeError中执行Uncaught后出现此消息错误:无法读取响应app.js:47293中未定义的属性“data”
我不知道为什么数据没有定义
谢谢
您忘了设置响应变量 我用这个解决问题
fetchDataResto(){
var vm = this
axios.get('/test')
.then(function (response){
Vue.set(vm.model, 'model', response.data)
})
}
fetchDataResto(){
var vm = this
axios.get('/test')
.then(function (response){
Vue.set(vm.$data, 'model', response.model.data)
})
}
fetchDataResto(){
var vm = this
axios.get('/test')
.then(function (response){
Vue.set(vm.model, 'model', response.data)
})
}