<!DOCTYPE html>
<html> <head>
<meta charset="UTF-8">
<title>v-for操作对象与数值</title>
<script src="vue.js"></script>
</head> <body>
<!--v-for操作对象-->
<div id="lantian">
<li v-for="(item,key,index) in user">
{{index}}——{{key}}——{{item}}
</li>
<!--v-for操作数值-->
<table border="1" width="100%">
<tr v-for="v in 20">
<td>{{v}}</td>
</tr>
</table>
</div> <script>
var app = new Vue({
el: '#lantian',
data: {
user: {
name: '小明',
age: '22',
sex: 'boy'
}
}
});
</script>
</body> </html>