小編給大家分享一下vue.js如何實(shí)現(xiàn)的全選與全不選功能,希望大家閱讀完這篇文章之后都有所收獲,下面讓我們一起去探討吧!
10年積累的成都做網(wǎng)站、成都網(wǎng)站設(shè)計(jì)經(jīng)驗(yàn),可以快速應(yīng)對(duì)客戶對(duì)網(wǎng)站的新想法和需求。提供各種問題對(duì)應(yīng)的解決方案。讓選擇我們的客戶得到更好、更有力的網(wǎng)絡(luò)服務(wù)。我雖然不認(rèn)識(shí)你,你也不認(rèn)識(shí)我。但先網(wǎng)站設(shè)計(jì)后付款的網(wǎng)站建設(shè)流程,更有安康免費(fèi)網(wǎng)站建設(shè)讓你可以放心的選擇與我們合作。
Vue是一套用于構(gòu)建用戶界面的漸進(jìn)式JavaScript框架,Vue與其它大型框架的區(qū)別是,使用Vue可以自底向上逐層應(yīng)用,其核心庫只關(guān)注視圖層,方便與第三方庫和項(xiàng)目整合,且使用Vue可以采用單文件組件和Vue生態(tài)系統(tǒng)支持的庫開發(fā)復(fù)雜的單頁應(yīng)用。
elementui是有checkbox組件,不過問題在于checkbox組件內(nèi)只能嵌套簡(jiǎn)單的字符串,如果要嵌入標(biāo)簽怎么辦?
首先渲染頁面:
<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" ></el-checkbox> <div class="num"> <a href="javascript:;" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >訂單號(hào):{{item.orderNumber}}</a> <p>商戶單號(hào):{{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">(運(yùn)費(fèi):{{item.postCost}})</span></td> </tr> </tbody>
初始化data數(shù)據(jù):
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:'童話鎮(zhèn)', phone:'12345678910', date:'2018-1-12', time:'09:30:00', state:'訂單關(guān)閉', 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:'童話鎮(zhèn)', phone:'12345678910', date:'2018-1-12', time:'09:30:00', state:'訂單關(guān)閉', pay:'400.00', postCost:'10.00' } ]
相關(guān)方法:
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; }
看完了這篇文章,相信你對(duì)“vue.js如何實(shí)現(xiàn)的全選與全不選功能”有了一定的了解,如果想了解更多相關(guān)知識(shí),歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道,感謝各位的閱讀!
網(wǎng)站名稱:vue.js如何實(shí)現(xiàn)的全選與全不選功能
文章URL:http://www.rwnh.cn/article28/ghsdcp.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供響應(yīng)式網(wǎng)站、Google、外貿(mào)建站、App開發(fā)、移動(dòng)網(wǎng)站建設(shè)、動(dòng)態(tài)網(wǎng)站
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)