我实际上是在youtube上学习Vue.js的教程,因此遇到了这个错误 我是第一次在这里发布问题。如果我做错了事,我提前道歉
错误:未被捕获的TypeError:无法读取未定义的属性“ push”
这是我正在观看的视频教程的链接,我被困在47:03 https://www.youtube.com/watch?v=z6hQqgvGI4Y
<template>
<div class="users">
<h1> Users </h1>
<form v-on:submit="addUser">
<input type="text" v-model="newUser.name" placeholder="Enter name">
<br />
<input type="text" v-model="newUser.email" placeholder="Enter email">
<br />
<input type="submit" value="submit">
</form>
<ul>
<li v-for="user in user">
<input type="checkbox">
{{user.name}}: {{user.email}}<button v-on:click="">delete</button>
</li>
</ul>
</div>
</template>
<script>
export default{
name: 'users',
data(){
return {
newUser:{},
user: [{
name: "Aanif Zia",
email: "aanif@hotmail.com",
contacted: false
},
{
name: "Annas Zia",
email: "annas@gmail.com",
contacted: false
},
{
name: "Siemel Zia",
email: "siemel@live.com",
contacted: false
}
]
}
},
methods: {
addUser: function(e){
this.users.push(
{
name: this.newUser.name,
email: this.newUser.email,
contacted: false,
});
e.preventDefault();
}
}
}
</script>
<style scoped>
</style>