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

在这里插入图片描述

Logo

前往低代码交流专区

更多推荐