zoukankan      html  css  js  c++  java
  • vue中v-for数组和对象的循环

    vue中v-for数组和对象的循环

    <!DOCTYPE html>
    <html lang="en">
    
    <head>
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Document</title>
        <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
    </head>
    
    <body>
        <div id="app">
            <ol>
                <li v-for="item,index in todos" :key="index">
                    {{ item.text }}-{{index}}
                </li>
            </ol>
            <ul>
                <li v-for="value,key in object" :key="key">
                    {{key}}:{{ value }}
                </li>
            </ul>
        </div>
        <script>
            var app = new Vue({
                el: '#app',
                data: {
                    todos: [{
                            text: '学习 JavaScript'
                        },
                        {
                            text: '学习 Vue'
                        },
                        {
                            text: '整个牛项目'
                        }
                    ],
                    object:{
                        title:"how to do lists in vue",
                        author:'ada',
                        publishedAt:'2021-07-04'
                    }
                }
            })
        </script>
    
    </body>
    
    </html>

    效果:

  • 相关阅读:
    状压DP
    数位dp
    浅谈网络最大流
    Luogu p2456 二进制方程
    dp基础√
    双联通分量与二分图
    是时候再写一篇新的博客了
    神仙网络最大流
    状态压缩dp相关
    图论 test solution
  • 原文地址:https://www.cnblogs.com/huanghuali/p/14968774.html
Copyright © 2011-2022 走看看