Vue v-for 循环

v-for循环

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>v-for循环</title>
    <script src="vue.js"></script>
</head>

<body>
    <div id="id01">
        <div v-for="(user, index) in userList" :key="user.id">ID:{
   
   {user.id}}、用户名:{
   
   {user,name_xy}}、引索:{
   
   {index}}</div>
    </div>
</body>

</html>
<script>
    var vm = new Vue({
     
     
        el: "#id01",
        data: {
     
     
            id: 0,
            name_xy: null,
            userList: [
                {
     
     id: 1, name_xy: "小印01"}, 
                {
     
     id: 2, name_xy: "小印02"}, 
                {
     
     id: 3, name_xy: "小印03"},
                {
     
     id: 4, name_xy: "小印04"}
            ]
        }
    })
</script>

一点点笔记,以便以后翻阅。

猜你喜欢

转载自blog.csdn.net/qq_44111597/article/details/109119216