国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > JavaScript > 正文

vue.js實現的全選與全不選功能示例【基于elementui】

2019-11-19 12:25:22
字體:
來源:轉載
供稿:網友

本文實例講述了vue.js實現的全選與全不選功能。分享給大家供大家參考,具體如下:

elementui是有checkbox組件,不過問題在于checkbox組件內只能嵌套簡單的字符串,如果要嵌入標簽怎么辦?

首先渲染頁面:

<el-checkbox v-model="checkAll" @change="handleCheckAllChange">全選</el-checkbox><tbody v-for="item in orderData"> <tr>  <td class="order-num" colspan="7">   <el-checkbox v-model="item.checkModel" @change="handleCheckItemChange" style="vertical-align:top;margin-top:20px;"></el-checkbox>   <div class="num">    <a href="javascript:;" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >訂單號:{{item.orderNumber}}</a>    <p>商戶單號:{{item.shopNumber}}</p>   </div>  </td>  <td class="order-action" colspan="2">   <a href="javascript:;" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >查看詳情</a>-<a href="javascript:;" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >備注</a>-<a href="javascript:;" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >加星</a>  </td> </tr> <tr>  <td>   <div class="pic">    <img :src=item.orderPic alt="">   </div>   <div class="info">    <a href="javascript:;" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >{{item.name}}</a>    <p>{{item.size}}</p>    <p>商品來源:{{item.from}}</p>   </div>  </td>  <td>{{item.number}}</td>  <td>{{item.price}}</td>  <td>-</td>  <td>{{item.company}}</td>  <td>   <p>{{item.address}}</p>   <p>({{item.phone}})</p>  </td>  <td>{{item.date}}<br />{{item.time}}</td>  <td>{{item.state}}</td>  <td>{{item.pay}}<br /><span v-if="item.postCost">(運費:{{item.postCost}})</span></td> </tr></tbody>

初始化data數據:

checkAll:false,checkedAllShops:[],checkItemData:[],orderData:[ {  checkModel:false,  orderNumber:'2017081618322542542',  shopNumber:'2017081618322542542',  orderPic:'../../../../static/images/realtimeprofile01.png',  name:'【商城】貼輕松穴位艾灸貼',  size:'5貼*盒',  from:'本店商品',  number:'10',  price:'200.00',  company:'蒂花之秀',  address:'童話鎮',  phone:'12345678910',  date:'2018-1-12',  time:'09:30:00',  state:'訂單關閉',  pay:'400.00',  postCost:'10' },{  checkModel:false,  orderNumber:'2017081618322542542',  shopNumber:'2017081618322542542',  orderPic:'../../../../static/images/realtimeprofile01.png',  name:'【商城】貼輕松穴位艾灸貼',  size:'5貼*盒',  from:'本店商品',  number:'10',  price:'200.00',  company:'蒂花之秀',  address:'童話鎮',  phone:'12345678910',  date:'2018-1-12',  time:'09:30:00',  state:'訂單關閉',  pay:'400.00',  postCost:'10.00' }]

相關方法:

handleCheckAllChange(val){ this.orderData.map((item,i)=>{  item.checkModel = val; })},handleCheckItemChange(val){ for(let i = 0,l = this.orderData.length;i < l;i ++){  if(this.orderData[i].checkModel !== val){   this.checkAll = false;   return;  } } this.checkAll = val;}

css代碼就不貼出來了,不好看,哈哈

感興趣的朋友還可以使用本站如下在線工具測試運行效果:

在線HTML/CSS/JavaScript前端代碼調試運行工具:
http://tools.VeVB.COm/code/WebCodeRun

在線HTML/CSS/JavaScript代碼運行工具:
http://tools.VeVB.COm/code/HtmlJsRun

希望本文所述對大家vue.js程序設計有所幫助。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 监利县| 泸水县| 光山县| 闽清县| 泸溪县| 山阴县| 六盘水市| 巴楚县| 昌图县| 鹤庆县| 成安县| 二手房| 班戈县| 温泉县| 双城市| 旬阳县| 汤原县| 固原市| 宝丰县| 潼关县| 石楼县| 梁山县| 于田县| 屏东市| 饶阳县| 法库县| 台州市| 睢宁县| 嘉荫县| 长海县| 丹巴县| 云霄县| 郎溪县| 北辰区| 大港区| 太原市| 济南市| 林周县| 冕宁县| 南郑县| 融水|