<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>添加学生</title>
<script src="https://cdn.jsdelivr.net/npm/vue@2"></script>
</head>
<body>
<div id = "app1" >
<button @click = "add">添加学生</button>
<button @click = "del">删除学生</button>
<table border="1" width="50%" style="border-collapse: collapse">
<tr>
<th>班级</th>
<th>姓名</th>
<th>性别</th>
<th>年龄</th>
</tr>
<tr align="center" v-for = "item in students">
<td>{{item.grade}}</td>
<td>{{item.name}}</td>
<td>{{item.gender}}</td>
<td>{{item.age}}</td>
</tr>
</table>
</div>
<script>
var vm = new Vue({
el:'#app1',
data:{
students: []
},
methods:{
//添加学生信息
add(){
var student = {grade: '1' ,name: '张三' ,gender: '男' ,age: '25' }
this.students.push(student)
},
del(){
this.students.pop()
}
}
})
</script>
</body>
</html>
03-16
1906

12-13
1063

12-08
1190

10-25
1088
