V-for rendering list

<!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>
</head>

<body>

    <div id="app">


        <h1 v-for="(student, index) in students">{{index}}-->{{student.name}}-->{{student.age}}</h1>

    </div>

    <script src="./vue.js"></script>


    <script>
        const app = new Vue({
            el: '#app',
            data: {
                students: [{
                        name: '江芦贵',
                        age: 20
                    },
                    {
                        name: '黄聪聪',
                        age: 20
                    },
                    {
                        name: '张康',
                        age: 20
                    },
                ]
            }
        });
    </script>
</body>

</html>
Published 151 original articles · won praise 1 · views 1873

Guess you like

Origin blog.csdn.net/qq_45802159/article/details/103816575