zoukankan      html  css  js  c++  java
  • vue-常用指令(v-for)

    v-for: 循环遍历
        1、遍历数组
        2、遍历对象
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/strict.dtd">
    <html>
    <head>
    <META http-equiv=Content-Type content="text/html; charset=UTF-8">
    <title></title>
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
    </head>
    <body>
    	<div id="app">
    		<ol>
    		    <!--遍历数组-->
    			<li v-for="(item,index) in items">
    				{{item.text}} -- {{index}}
    			</li>
    		</ol>
    		
    		----------------------------------------
    		<!--遍历对象-->
    		<ul>
    			<li v-for="(value,key,index) in obj">
    			  {{value}} -- {{key}} -- {{index}}
    			</li>
    		</ul>
    		
    		<button v-on:click="appendItem">追加</button>
    	</div>
    </body>
    <script>
       var app = new Vue({
    		el: '#app',
    		data: {
    			items: [
    				{text: 'SpringMVC'},
    				{text: 'Spring'},
    				{text: 'Mybatis'}
    			],
    			obj: {
    				"name": "zhangsan",
    				"age": 12,
    				"sex": "男"
    			}
    		},
    		methods: {
    			appendItem: function() {
    				app.items.push({text: 'append new item'})
    			}
    		}
       });
    </script>
    </html>
        
    

      

  • 相关阅读:
    hdu 1104 数论+bfs
    hdu 1019 最小公倍数
    hdu 1005 数论 循环
    山东省第三届acm
    hdu 1576
    浏览器支持
    FormData
    获取APP图片资源
    链接转标签
    bug20170125
  • 原文地址:https://www.cnblogs.com/yuefeng123/p/12858632.html
Copyright © 2011-2022 走看看