zoukankan      html  css  js  c++  java
  • v-for示例二

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Document</title>
        <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
    </head>
    <body>
        <div id="app">
            <li v-for="(book,index) in books" >{{index}}--{{book.name}}</li>
    // 遍历对象属性时,有两个可选参数,分别是键名和索引:
            <p v-for="(value,key,index) in userInfo">{{index}}--{{key}}--{{value}}</p>
        </div>
        <script>
            var v=new Vue({
                el:"#app",
                data:{
                    books:[{'name':'java编程思想'},{'name':'java设计模式'}],
                    userInfo:{
                        'name':'zhangsan',
                        'age':28
                    }
                }
            });
        </script>
    </body>
    </html>
  • 相关阅读:
    Reverse Linked List
    Sqrt(x)
    Convert Sorted Array to Binary Search Tree
    Remove Linked List Elements
    Happy Number
    Length of Last Word
    Pow(x, n)
    Rotate Image
    Permutations
    Integer to Roman
  • 原文地址:https://www.cnblogs.com/kukai/p/12853420.html
Copyright © 2011-2022 走看看