<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Vue-指令-案例</title>
<script src="JS/vue.js"></script>
<style>
/* //设置表格的边距 */
table{
margin: 0 auto;
}
</style>
</head>
<body>
<div id="app">
<table border="1" cellspacing="0" width="60%">
<tr>
<td>编号</td>
<td>姓名</td>
<td>年龄</td>
<td>性别</td>
<td>成绩</td>
<td>等级</td>
</tr>
<tr align="center" v-for="(user,index) in User">
<td>{{index+1}}</td>
<td>{{user.name}}</td>
<td>{{user.age}}</td>
<td>
<span v-if="user.gender == 1">男</span>
<span v-else="user.gender == 2">女</span>
</td>
<td>{{user.score}}</td>
<td>
<span v-if="user.score >= 80">优秀</span>
<span v-else-if="user.score >= 60 && user.score < 80">及格</span>
<span v-else="user.score < 60" style="color: red;">不及格</span>
</td>
</tr>
</table>
</div>
</body>
<script>
new Vue({
el: "#app",
data: {
User: [{
name: "",
age: 18,
gender: 1,
score: 90,
}, {
name: "",
age: 19,
gender: 1,
score: 100,
}, {
name: "",
age: 20,
gender: 1,
score: 60,
}, {
name: "",
age: 18,
gender: 2,
score: 100,
}]
}
})
</script>
</html>
标签:name,gender,age,60,score,user,10.17 From: https://www.cnblogs.com/gjsgjs/p/17790755.html