1. <!DOCTYPE html>
    2. <html lang="en">
    3. <head>
    4. <meta charset="UTF-8">
    5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
    6. <meta http-equiv="X-UA-Compatible" content="ie=edge">
    7. <title>Document</title>
    8. <script src="./lib/vue.js"></script>
    9. </head>
    10. <body>
    11. <div id="app">
    12. <!-- 索引在最后面,key在第二位,第一位是值 -->
    13. <p v-for="(val, key,i) in userObj">值是{{val}} 键是{{key}} 索引是{{i}}</p>
    14. </div>
    15. <script>
    16. var vm = new Vue({
    17. el: '#app',
    18. data: {
    19. userObj: {
    20. "name": "aaa",
    21. "age": 12,
    22. gender:"男"
    23. }
    24. },
    25. methods: {}
    26. });
    27. </script>
    28. </body>
    29. </html>

    image.png