微信掃碼登錄 ×
vue bootstrap動(dòng)態(tài)表格編輯代碼

vue bootstrap動(dòng)態(tài)表格編輯代碼

收藏
vue bootstrap動(dòng)態(tài)表格編輯代碼
vue基于bootstrap制作動(dòng)態(tài)表格添加刪除行列表和編輯修改行內(nèi)容效果代碼。

使用方法:

1、head引入css文件

<link rel="stylesheet" href="css/bootstrap.min.css"/>

2、head引入js文件

<script src="js/jquery-1.7.2.min.js"></script>
<script src="js/bootstrap.js"></script>
<script src="js/vue.js"></script>
<script>
	  window.onload = function(){
		  new Vue({
			  el:'#box',
			  data:{
				 myData:[],
				 nowIndex:-100
			  },
			  methods:{
				 add:function(){
					  this.myData.push({
					  })
				 },
				  del:function(n){
					  if(n ==-2){
						  this.myData="";
					  }else{
						  this.myData.splice(n,1);
					  }
				  }
			  }
		  })
	  }
</script>

3、body引入部分

<div class="container" id="box">
	 <table class="table table-bordered table-hover">
		 <caption class="h3 text-info">布料詳細(xì)表</caption>
		 <tr>
			 <th class="text-center" style="width: 5%;">序號(hào)</th>
			 <th class="text-center" style="width: 55%;">布類</th>
			 <th class="text-center" style="width: 10%;">克重</th>
			 <th class="text-center" style="width: 10%;">單位</th>
			 <th class="text-center" style="width: 10%;">單價(jià)</th>
			 <th class="text-center"><input type="button"  value="+" class="btn btn-primary" v-on:click="add()"/></th>
		 </tr>
		 <tr class="text-center" v-for="item in myData">
			<td>{{$index+1}}</td>
			<td>
					<select id="fab" name="fab" style="width:90%">
					<option value="1">30s/1 精梳棉 疋染 1x1 羅紋布 (正常整理)</option>
					<option value="2">32s/1 精梳棉 + 70D 彈性纖維 疋染凈色 1x1 羅紋布 (正常整理)</option>
					<option value="3">32s/1x2 CVC 60/40 疋染  抓毛位衣 (磨毛(面))</option>
					<option value="4">32s/1 CVC 60/40 疋染 平紋布 (正常整理)</option>
					<option value="5">26s/1 精梳棉 疋染凈色 1x1 羅紋布 (蝕毛)</option>
					<option value="6">20s/1x3 精梳棉 疋染 扁機(jī)領(lǐng)(ottoman) (正常整理)</option> 
					</select>
			</td>
			<td>
				<input type="text" id="weight" name="weight" style="width:90%"/>
				
			</td>
			<td>
				<input type="text" id="unit" name="unit" style="width:90%"/>
			</td>
			<td>
				<input type="text" id="price" name="peice" style="width:45%"/>
			</td>
			<td>
				 <button class="btn btn-del btn-sm" data-toggle="modal" data-target="#layer" v-on:click="nowIndex=$index">X</button>
			</td>
		 </tr>
		 <tr v-show="myData.length==0">
			 <td colspan="6" class="text-center text-info">
				 <p>暫無(wú)數(shù)據(jù)...</p>
			 </td>
		 </tr>
	 </table>
	 <!--彈出框-->
	 <div role="dialog" class="modal fade" id="layer" data-index="{{nowIndex}}">
		  <div class="modal-dialog">
			  <div class="modal-content">
				  <div class="modal-header">
					  <button class="close" data-dismiss="modal">
						  <span>×</span>
					  </button>
					  <h4 class="modal-title">確認(rèn)刪除嗎?</h4>
				  </div>
				  <div class="modal-body text-right">
					  <button class="btn btn-cancel btn-sm" data-dismiss="modal">取消</button>
					  <button class="btn btn-danger btn-sm" data-dismiss="modal" v-on:click="del(nowIndex)">確認(rèn)</button>
				  </div>
			  </div>
		  </div>
	 </div>
 </div>

使用聲明

1. 本站所有素材(未指定商用),僅限學(xué)習(xí)交流。
2. 會(huì)員在本站下載的原創(chuàng)商用和VIP素材后,只擁有使用權(quán),著作權(quán)歸原作者及17素材網(wǎng)所有。
3. 原創(chuàng)商用和VIP素材,未經(jīng)合法授權(quán),請(qǐng)勿用于商業(yè)用途,會(huì)員不得以任何形式發(fā)布、傳播、復(fù)制、轉(zhuǎn)售該素材,否則一律封號(hào)處理。
4. 本平臺(tái)織夢(mèng)模板僅展示和個(gè)人非盈利用途,織夢(mèng)系統(tǒng)商業(yè)用途請(qǐng)預(yù)先授權(quán)。

x
×
×

注冊(cè)

QQ注冊(cè) 立即下載 微信注冊(cè) 立即下載

簽到成功!

已連續(xù)簽到1天,連續(xù)簽到3天可獲得50積分

知道了