<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<script src="https://cdn.staticfile.org/vue/2.2.2/vue.min.js"></script>
</head>
<body>
<div id="app">
<!-- 没有使用索引值 -->
<ul>
<li v-for="item in fruit">{{item}}</li>
</ul>
<!-- 在遍历的过程中使用索引值 -->
<ul>
<li v-for="(item,index) in fruit">{{index+1}}:{{item}}</li>
</ul>
<!-- 使用v-for遍历对象,此时使用item显示出来的是值 -->
<ul>
<li v-for='item in info'>{{item}}</li>
</ul>
<!-- 使用v-for遍历对象,此时显示的包括键和值 -->
<ul>
<li v-for='(key,item) in info'>{{key}}:{{item}}</li>
</ul>
</div>
<script>
var vm=new Vue({
el: '#app',
data: {
fruit: ['apple','banana','orange','grape'],
info: {
name: 'Mary',
age: 22,
height: 167
}
},
computed: {},
methods: {}
})
</script>
</body>
</html>