Vue 添加数据到二维数组并显示
<li v-for="(item, index) in studentlist" :key="index">{{item.stu_name}}--{{item.stu_score}}</li><td><tr><span id="student_name">学生姓名</span>...
·
<li v-for="(item, index) in studentlist" :key="index">
{{item.stu_name}}--{{item.stu_score}}
</li>
<td>
<tr>
<span id="student_name">学生姓名</span>
<input type="text" v-model="student_name">
</tr>
</td>
<td>
<tr>
<span id="student_score">期末成绩</span>
<input type="text" v-model="student_score">
</tr>
</td>
实现:
export default {
name: 'Index',
data () {
return {
student_name: '',
student_score: '',
studentlist: []
}
},
methods: {
addstudent () {
this.studentlist.push({
stu_name: this.student_name,
stu_score: this.student_score
})
console.log(this.studentlist)
}
}
}
</script>
更多推荐
已为社区贡献7条内容
所有评论(0)