1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
| <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> <script src="../02_js/vue.js"></script> </head> <body>
<div id="d1"> <table border="1px" width="500px" cellspacing="0px"> <tr> <th>序号</th> <th>姓名</th> <th>年龄</th> <th>性别</th> <th>分数</th> <th>等级</th> </tr> <tr v-for="(stu,i) in stus"> <td>{{i+1}}</td> <td>{{stu.name}}</td> <td>{{stu.age}}</td> <td>{{stu.sex ==1?'男':'女'}}</td> <td>{{stu.score}}</td> <td> <span v-if="stu.score < 0 || stu.score > 100" style="color: red;">不合法</span> <span v-else-if="stu.score < 60" style="color: red;">不及格</span> <span v-else-if="stu.score < 80" style="color: green;">良好</span> <span v-else>优秀</span> </td> </tr> </table> </div>
<script> new Vue({ el:"#d1", data:{ stus:[ { name:'张三', age:18, sex:1, score:67 }, { name:'李四', age:19, sex:2, score:97 }, { name:'王五', age:16, sex:1, score:17 }, { name:'赵六', age:16, sex:1, score:-17 } ] }, methods: { }, }); </script> </body> </html>
|