Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vue.js/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vue.js 未捕获(承诺中)TypeError:无法读取未定义的属性“data”_Vue.js_Vuejs2 - Fatal编程技术网

Vue.js 未捕获(承诺中)TypeError:无法读取未定义的属性“data”

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{

我对VueJS Laravel有这个问题

这是我的家

<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)
                    })
            }