欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

vue.js 嵌套循環(huán)、if判斷、動(dòng)態(tài)刪除的實(shí)例

 更新時(shí)間:2018年03月07日 15:06:58   作者:愛(ài)代碼也愛(ài)生活  
下面小編就為大家分享一篇vue.js 嵌套循環(huán)、if判斷、動(dòng)態(tài)刪除的實(shí)例,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧

Vue.js是當(dāng)下很火的一個(gè)JavaScript MVVM庫(kù),它是以數(shù)據(jù)驅(qū)動(dòng)和組件化的思想構(gòu)建的。相比于Angular.js,Vue.js提供了更加簡(jiǎn)潔、更易于理解的API

app.html

<!doctype html>
<html lang="zh-CN">
<head>
 <meta charset="UTF-8">
	<title>
	vuejs 嵌套循環(huán)、if判斷
	</title>
	<style type="text/css">
		[v-cloak] { display: none }
	</style>
</head>
<body>
 <div id="app">
		
		<table>
			<tr>			
				<td >id</td>
				<td >姓名</td>
				<td >手機(jī)號(hào)</td>
				<td >城市</td>
				
				<td >通過(guò)審核</td>
				<td >我的學(xué)生</td>
				<td >操作</td>				
			</tr>
		 <tr v-for="(item,index) in list "> 
			 <td>{{item.id}}</td> 
			 <td>{{item.name}}</td>
			 <td>{{item.tel}}</td> 
				
			 <td>{{item.province}}_{{item.city}}</td> 
				<td v-if="item.status==1">是</td> 
				<td v-else-if="item.status==0">否</td> 
				<td >
					<span v-for="stu in item.stu ">
					{{stu.name}},
					</span>
				</td> 
				<td>
				 <button v-on:click="edit">修改</button>
				 <button v-on:click="del(index)">刪除</button>
				</td> 
		 </tr>
		</table>
 </div>
</body>
<script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js" charset="utf-8"></script>
<script src="https://cdn.bootcss.com/vue/2.3.0/vue.min.js" charset="utf-8"></script>
<script type="text/javascript">
$(function() {
 new Vue({ 
		el: '#app', 
	 methods: { 
			del:function(index){
				this.list.splice(index,1);
			},
			edit: function () {
				alert('修改')
			},
		},
	 data: {
			"list":[{
				"id":"139",
				"name":"王五",
				"tel":"13681829898",
				"status":"1",
				"province":"省",
				"city":"市",
				"sex":"1",
				"stu":[{
					"id":"200",
					"name":"學(xué)生1",
					"tel":"13681829898",
				},{
					"id":"201",
					"name":"學(xué)生2",
					"tel":"13681829898",
				}],
			},
			{
				"id":"138",
				"name":"麻子",
				"tel":"13681829898",
				"status":"0",
				"province":"省",
				"city":"市",
				"sex":"0",
				"stu":[{
					"id":"300",
					"name":"學(xué)生31",
					"tel":"13681829898",
				},{
					"id":"301",
					"name":"學(xué)生32",
					"tel":"13681829898",
				}],
			},
			{
				"id":"137",
				"name":"麗麗",
				"tel":"15152882891",
				"status":"0",
				"province":"省",
				"city":"市",
				"sex":"1",
				"stu":[{
					"id":"400",
					"name":"學(xué)生41",
					"tel":"13681829898",
				},{
					"id":"401",
					"name":"學(xué)生42",
					"tel":"13681829898",
				}],
			},
			{
				"id":"136",
				"name":"娜娜",
				"tel":"15152882891",
				"status":"0",
				"province":"省",
				"city":"市",
				"sex":"0",
				"stu":[{
					"id":"500",
					"name":"學(xué)生51",
					"tel":"13681829898",
				},{
					"id":"501",
					"name":"學(xué)生52",
					"tel":"13681829898",
				}],
			}]
	 }
	})
})
</script>
</html>

vue1.0和vue2.0循環(huán)索引使用區(qū)別

如果是vue1.0這樣寫:
<ol>
   <li v-for="todo in todos" @click="delete($index)">
     {{todo.label}}
   </li>
</ol>
然后:
methods:{
 
 delete:function(index){
  this.todos.splice(index,1);
 }
}
如果是vue2.0這樣寫:
<ol>
    <li v-for="(todo,index) in todos" @click="delete(index)">
     {{todo.label}}
    </li> 
</ol>
然后
methods:{
 
 delete:function(index){
  this.todos.splice(index,1);
 }
}

以上這篇vue.js 嵌套循環(huán)、if判斷、動(dòng)態(tài)刪除的實(shí)例就是小編分享給大家的全部?jī)?nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。

相關(guān)文章

  • Vuex入門到上手教程

    Vuex入門到上手教程

    這篇文章主要介紹了Vuex入門到上手教程,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧
    2018-06-06
  • Vue Extends 擴(kuò)展選項(xiàng)用法完整實(shí)例

    Vue Extends 擴(kuò)展選項(xiàng)用法完整實(shí)例

    這篇文章主要介紹了Vue Extends 擴(kuò)展選項(xiàng)用法,結(jié)合完整實(shí)例形式分析了Vue Extends 擴(kuò)展選項(xiàng)相關(guān)使用技巧與操作注意事項(xiàng),需要的朋友可以參考下
    2019-09-09
  • vue.js指令v-model實(shí)現(xiàn)方法

    vue.js指令v-model實(shí)現(xiàn)方法

    這篇文章主要為大家詳細(xì)介紹了vue.js指令v-model實(shí)現(xiàn)方法,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2016-12-12
  • vue中如何使用embed標(biāo)簽PDF預(yù)覽

    vue中如何使用embed標(biāo)簽PDF預(yù)覽

    這篇文章主要介紹了vue中如何使用embed標(biāo)簽PDF預(yù)覽,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2022-05-05
  • Windows系統(tǒng)下使用nginx部署vue2項(xiàng)目的全過(guò)程

    Windows系統(tǒng)下使用nginx部署vue2項(xiàng)目的全過(guò)程

    nginx是一個(gè)高性能的HTTP和反向代理服務(wù)器,因此常用來(lái)做靜態(tài)資源服務(wù)器和后端的反向代理服務(wù)器,下面這篇文章主要給大家介紹了關(guān)于Windows系統(tǒng)下使用nginx部署vue2項(xiàng)目的相關(guān)資料,需要的朋友可以參考下
    2023-03-03
  • Vue3?echarts組件化及使用hook進(jìn)行resize方式

    Vue3?echarts組件化及使用hook進(jìn)行resize方式

    這篇文章主要介紹了Vue3?echarts組件化及使用hook進(jìn)行resize方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2023-04-04
  • Vue組件實(shí)現(xiàn)觸底判斷

    Vue組件實(shí)現(xiàn)觸底判斷

    這篇文章主要為大家詳細(xì)介紹了Vue組件實(shí)現(xiàn)觸底判斷,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2019-06-06
  • 詳解Vue的列表渲染

    詳解Vue的列表渲染

    這篇文章主要為大家介紹了Vue的列表渲染,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下,希望能夠給你帶來(lái)幫助
    2021-11-11
  • vue3實(shí)現(xiàn)動(dòng)態(tài)添加路由

    vue3實(shí)現(xiàn)動(dòng)態(tài)添加路由

    這篇文章主要介紹了vue3實(shí)現(xiàn)動(dòng)態(tài)添加路由方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2024-04-04
  • mockjs+vue頁(yè)面直接展示數(shù)據(jù)的方法

    mockjs+vue頁(yè)面直接展示數(shù)據(jù)的方法

    這篇文章主要介紹了mockjs+vue頁(yè)面直接展示數(shù)據(jù)的方法,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧
    2018-12-12

最新評(píng)論