作用:循环列表

    1. <!DOCTYPE html>
    2. <html lang="en">
    3. <head>
    4. <meta charset="UTF-8">
    5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
    6. <meta http-equiv="X-UA-Compatible" content="ie=edge">
    7. <title>v-on事件绑定</title>
    8. <style>
    9. .box {
    10. width: 200px;
    11. height: 200px;
    12. background-color: red;
    13. }
    14. .active {
    15. background-color: green;
    16. }
    17. </style>
    18. </head>
    19. <body>
    20. <div id='app'>
    21. <div>
    22. <ul>
    23. <li v-for = '(item,index) in menus' :key = 'item.id'>
    24. <h3>{{index}} - id:{{item.id}} 菜名:{{item.name}}</h3>
    25. </li>
    26. </ul>
    27. <ol>
    28. <li v-for = "(val,key) in obj" :key='key'>
    29. {{key}}---{{val}}
    30. </li>
    31. </ol>
    32. </div>
    33. </div>
    34. <script src="./vue.js"></script>
    35. <script>
    36. new Vue({
    37. el: '#app',
    38. data: {
    39. menus:[
    40. {id:1,name:'大腰子'},
    41. {id:2,name:'烤鸡翅'},
    42. {id:3,name:'烤韭菜'},
    43. {id:4,name:'烤大蒜'},
    44. ],
    45. obj:{
    46. title:'hello 循环',
    47. author:'ecithy'
    48. }
    49. },
    50. methods: {
    51. },
    52. })
    53. </script>
    54. </body>
    55. </html>