data数据为sex的value为1或0,呈现的时候显示为“男”或“女”
<!DOCTYPE html><html><head lang="en"><meta charset="UTF-8"><script src="js/vue.js"></script&a
·
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<script src="js/vue.js"></script>
<title></title>
</head>
<body>
<div id="container">
<table>
<thead>
<tr>
<th>姓名</th>
<th>性别</th>
<th>年龄</th>
</tr>
</thead>
<tbody>
<tr v-for="tmp in stuList">
<!--<td v-for="value in tmp">-->
<!--{{value}}-->
<!--</td>-->
<td>{{tmp.name}}</td>
<!--<td>{{tmp.sex}}</td>-->
<td>{{tmp.sex>0?'男':'女'}}</td>
<td>{{tmp.age}}</td>
</tr>
</tbody>
</table>
</div>
<script>
new Vue({
el:'#container',
data:{
stuList:[
{name:'michael',sex:1,age:20},
{name:'miller',sex:1,age:21},
{name:'lincoln',sex:0,age:23},
{name:'lucy',sex:1,age:22},
{name:'hanmeimei',sex:0,age:19}
]
}
})
</script>
</body>
</html>
更多推荐
已为社区贡献2条内容
所有评论(0)