[英]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.