午夜剧场伦理_日本一道高清_国产又黄又硬_91黄色网战_女同久久另类69精品国产_妹妹的朋友在线

您的位置:首頁技術文章
文章詳情頁

vue使用vant中的checkbox實現全選功能

瀏覽:12日期:2022-10-26 16:41:45

本文實例為大家分享了vue使用vant中的checkbox實現全選功能的具體代碼,供大家參考,具體內容如下

<template> <div class='visiblePeople'> <topbar /> <ul class='list clear_float'> <li v-for='(item, index) in people' :key='index'> <van-checkbox v-model='item.flag' ></van-checkbox> <div class='right'> <p>{{ item.name }}</p> <p>{{ item.id }}</p> </div> </li> </ul> <div class='bottom'> <div class='left'> <van-checkbox v-model='allcheck' class='all'>全選</van-checkbox> </div> <button @click='jump'>確定</button> </div> </div></template> <script>export default { data() { return { people: [ { id: '002', name: '陳陽', flag: true }, { id: '003', name: '王苗苗', flag: true, }, { id: '004', name: '張梁俊', flag: true, }, { id: '005', name: '劉路', flag: true, }, ], }; }, methods: { //點擊確定后跳轉回新增合同頁面 jump() { this.$router.push('/addContract'); }, //單選按鈕切換 // change(index) { // this.people[index].flag = !this.people[index].flag; // console.log(this.people[index].flag); // }, }, computed:{ allcheck:{ get(){ //取值 //every方法,數組中每一項都滿足一個條件返回true return this.people.every(item=>item.flag) }, set(newValue){ //設置值 console.log(’觸發set方法’) this.people.map(item=>item.flag=newValue) } }, filterAll(){ return this.people.filter(item=>item.flag).length }, count(){ let checkedList=this.people.filter(item=>item.flag) return checkedList.length.reduce((total,item)=>{ return total+item.num },0) } }};</script><style lang='less' scoped>.list { background: #f8f9fb; height: 574px; li { height: 56px; margin: 10px 0 10px 0; float: left; img { width: 19px; height: 19px; float: left; margin: 13px; &.on { display: block; } &.off { display: none; } } .listli { float: left; margin: 19px 13px 0 13px; } .right { float: left; background: #ffffff; width: 328px; height: 56px; padding: 0px 0 0 13px; box-sizing: border-box; p:nth-of-type(1) { font-size: 15px; font-family: PingFang SC; font-weight: 400; color: #000000; line-height: 29px; } p:nth-of-type(2) { font-size: 13px; font-family: PingFang SC; font-weight: 400; color: #666666; line-height: 14px; } } }}.bottom { height: 50px; position: fixed; bottom: 0; .left { width: 237px; background: #ffffff; height: 100%; float: left; img { width: 18px; float: left; margin: 18px 13px 0 18px; &.on { display: block; } &.off { display: none; } } .all { margin: 17px 0 0 14px; } p { float: left; font-size: 13px; font-family: PingFang SC; font-weight: 400; color: #333333; margin-top: 18px; } } button { float: left; width: 138px; height: 50px; line-height: 50px; background: #336afa; color: #ffffff; }}</style>

本次遇到的問題是自己一開始沒發現在people數組里面,定義的每一項flag的值設置的類型為字符串型即flag='true',導致一開始進入頁面全部無論值為true還是false,復選框都是選中效果,修改之后便沒有了此問題。

關于vue.js組件的教程,請大家點擊專題vue.js組件學習教程進行學習。

更多vue學習教程請閱讀專題《vue實戰教程》

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持好吧啦網。

標簽: Vue
相關文章:
主站蜘蛛池模板: 成年人网站在线 | 日韩av成人 | 毛片网站在线免费观看 | 成人福利视频导航 | 免费网站www在线观看 | 欧美国产一区二区 | 久久有精品| 国产怡春院 | 91变态视频 | 蜜桃av噜噜一区二区三区麻豆 | 免费国产一区二区三区 | 黄色a级片在线观看 | 国产麻豆一级片 | 日韩av网站在线 | 免费中文字幕在线观看 | 日韩在线视频免费看 | 亚洲欧美综合一区 | 色综合天天综合网国产成人网 | 四虎永久网站 | 日韩av一级片| 欧美福利视频在线观看 | 最近中文字幕在线中文高清版 | 中文av在线播放 | 黄色免费看网站 | 国产专区视频 | 天天色视频| 亚洲综合二区 | 欧美国产日韩一区二区 | 黄色大片av | 伊人热久久 | 五月天堂网 | 亚洲精品资源 | 四虎www.| 91日韩国产 | 日韩一区二区在线免费观看 | 国产视频第一区 | 91 禁| 欧美性受xxx黑人xyx性爽 | 天天色天天操天天射 | av日韩一区 | 成人一级大片 |