<!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>
</head>
<body>
<div id="app">
<table border="1" cellspacing="0" width="60%">
<tr>
<th>编号</th>
<th>作者</th>
<th>书名</th>
<th>价格</th>
<th>出版日期</th>
<th>评价</th>
</tr>
<tr align="center" v-for="(user,index) in users">
<td>{{index+1}}</td>
<td>{{user.author}}
<span v-if="user.gender==1">(男)</span>
<span v-if="user.gender==2">(女)</span>
</td>
<td>{{user.book}}</td>
<td>{{user.price}}</td>
<td>{{user.date}}</td>
<td>
<span v-if="user.price<=23">价格亲民</span>
<span v-else>有点小贵</span>
</td>
</tr>
</table>
</div>
</body>
<script>
new Vue({
el:"#app",
data:{
users: [{
author:"小华",
gender:2,
book:"《春天来了》",
price:23,
date:"1998-03-12"
},{
author:"老舍",
gender:1,
book:"《济南的冬天》",
price:32,
date:"1956-12-09"
},{
author:"朱自清",
gender:1,
book:"《背影》",
price:40,
date:"1943-09-12"
}],
methods:{
}
}
})
</script>
</html>