• v-for


    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="utf-8">
    <title></title>
    <script src="vue.js"></script>
    </head>
    <body>
    <div id="vue-app08">
    <h1>v-for循环</h1>
    <!-- 数组下标 -->
    <!-- {{characters[0]}}
    {{characters[1]}}
    {{characters[2]}} -->
    <!-- 数组遍历 -->
    <ul>
    <li v-for="x in characters">
    {{x}}
    </li>
    </ul>

    <ul>
    <li v-for="y in users">
    {{y.name}}-{{y.age}}
    </li>
    </ul>

    <ul>
    <!-- index索引 -->
    <li v-for="(y,index) in users">
    {{index}}. {{y.name}}-{{y.age}}
    </li>
    </ul>

    <div v-for="(y,index) in users">
    <h3>{{index}}.{{y.name}}</h3>
    <p>Age - {{y.age}}</p>
    </div>
    <template v-for="(y,index) in users">
    <h3>{{index}}.{{y.name}}</h3>
    <p>Age - {{y.age}}</p>
    </template>

    <template v-for="(y,index) in users">
    <div v-for="(val,key) in y">
    <p>{{key}} - {{val}}</p>
    </div>
    </template>
    </div>
    <script src="v-for.js" type="text/javascript" charset="utf-8"></script>
    </body>
    </html>

    new Vue({
    el:"#vue-app08",
    data:{
    //两个数组
    characters:["小红","小敏","小里"],
    users:[
    {name:"Henry",age:30},
    {name:"lily",age:20},
    {name:"locy",age:10},
    ]
    },
    methods:{

    },
    computed:{

    }
    })

  • 相关阅读:
    子类构造函数 supper关键字
    匿名内部类
    IK 分词器 源码分析
    java重写equals方法
    java编程思想
    设置centos7默认运行级别
    centos7配置wordpress
    python安装tkinter
    centos 7编译安装apache
    关于python中带下划线的变量和函数 的意义
  • 原文地址:https://www.cnblogs.com/weixin2623670713/p/12913006.html
Copyright © 2020-2023  润新知