简体   繁体   English

Vue.js - 类型错误:无法读取未定义的属性“标题”

[英]Vue.js - TypeError: Cannot read property 'title' of undefined

I do not seem to know the solution of this error.我似乎不知道这个错误的解决方案。 I tried changing the title to 'title' still its the same error我尝试将标题更改为“标题”仍然是相同的错误

methods.vue:方法.vue:

<template>
    <div>
       <h1>we can have some data here, data number {{ counter }}</h1> 
       <button @click="UpdateCounter(1)">Up</button>
           <button @click="UpdateCounter(-1)">Down</button>
           <div v-for="(peoples,i) in people" :key="i" v-if="people.length">
               <h1>{{info.title}}</h1>
           </div>
    </div>
</template>

<script>
export default {
data() {
    return {
    counter:0,
    people:[],
    }
},
methods: {
    UpdateCounter(number){
    this.counter+=number;
    },

},
created() {
let info =[
    {title:'harout', 'surname':'deurdulian' , id:1},
    {title:'set', 'surname':'deurdulian' , id:2},
    {title:'meg', 'surname':'mav' , id:3},
    {title:'sevag', 'surname':'mav' , id:4},
]
this.people=info
},
}
</script>

The error is caused by this line <h1>{{info.title}}</h1> :该错误是由这一行<h1>{{info.title}}</h1>引起的:

    <div v-for="(peoples,i) in people" :key="i" v-if="people.length">
               <h1>{{info.title}}</h1>
           </div>

change it to <h1>{{peoples.title}}</h1> because the info is undefined as a property in the component options.将其更改为<h1>{{peoples.title}}</h1>因为该info未定义为组件选项中的属性。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 TypeError:无法读取未定义的属性“标题”。 Vue.js - TypeError: Cannot read property 'title' of undefined. Vue.js “类型错误:无法读取未定义的属性‘服务’”Vue.js + Vuefire - "TypeError: Cannot read property 'servicios' of undefined" Vue.js + Vuefire Vue.js TypeError:消息无法读取未定义的属性“ singlePost” - Vue.js TypeError: Message Cannot read property 'singlePost' of undefined TypeError:无法读取未定义的Flatpickr&Vue.js属性“ add” - TypeError: Cannot read property 'add' of undefined" Flatpickr & Vue.js 无法读取vue.js中“未定义”的属性 - Cannot read property of 'Undefined' in vue.js Vue.js 计算属性:[Vue 警告]:渲染错误:“TypeError:无法读取未定义的属性‘userId’” - Vue.js computed property : [Vue warn]: Error in render: "TypeError: Cannot read property 'userId' of undefined" TypeError:无法读取未定义的“已创建”属性,未定义错误“Vue” Vue.js 3 - TypeError: Cannot read property 'created' of undefined, error 'Vue' is not defined Vue.js 3 vue.js:属性或方法“”未定义,渲染错误:“TypeError:无法读取未定义的属性” - vue.js : Property or method "" is not defined, Error in render: "TypeError: Cannot read property '' of undefined" data()中的错误:“ TypeError:无法读取未定义的属性&#39;length&#39;”(Vue.js) - Error in data(): “TypeError: Cannot read property 'length' of undefined” (Vue.js) vue.js push给出TypeError:无法读取未定义的属性“名称” - vue.js push gives TypeError: Cannot read property 'name' of undefined
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM