image.png

代码

<!DOCTYPE html>
<html lang="zh-cn">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Vue.js中v-for循环指令-对象迭代显示中参数的使用</title>
    <script src="//static.gzj2001.com/vue/vue.js"></script>
</head>

<body>
    <div id="app">
        <div v-for="value in obj1">{{value}}</div>
<hr>
        <div v-for="(value,key) in obj1">{{key}}:{{value}}</div>
        <hr>
        <div v-for="(value,key,index) in obj1">
            {{index}}=={{key}}:{{value}}
        </div>
    </div>
    <script>
        new Vue({
            el: "#app",
            data: {
                obj1: { id: "1", name: "allen1" },
                obj2: { id: "2", name: "allen2" },
                obj3: { id: "3", name: "allen3" },
            }
        })
    </script>
</body>

</html>