v-for循环对象
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script src="https://cdn.staticfile.org/vue/2.6.10/vue.js"></script>
<style>
</style>
</head>
<body>
<div id="app">
<p v-for="(val,key,i) in user">{{key}}:{{val}}----{{i}}</p><!--注意:在遍历对象身上的键值对的时候,除了有val,key,在第三个位置还有一个索引-->
</div>
<script>
var vm = new Vue({
el: '#app',
data: {
user:{
id:1,
name:'pwr',
gender:'男'
}
},
methods: {}
})
</script>
</body>
</html>