标签:script UNC function src style col 应用 val als
1.用computed实现全选
1 <body> 2 <div id="app"> 3 <input type="checkbox" v-model="checkAll">全选 4 <input type="checkbox" v-for="(item,index) in checks" :key="index" v-model="item.flag"> 5 </div> 6 <script src="./node_modules/vue/dist/vue.js"></script> 7 <script> 8 let vm = new Vue({ 9 data:{ 10 checks:[{flag:true},{flag:false},{flag:true}] 11 }, 12 computed:{ 13 checkAll:{ 14 get(){ 15 return this.checks.every(function(item){ 16 return item.flag; 17 }); 18 }, 19 set(value){ 20 this.checks.forEach(element => { 21 element.flag = value; 22 }); 23 } 24 } 25 } 26 }).$mount("#app"); 27 </script> 28 29 </body>
标签:script UNC function src style col 应用 val als
原文地址:https://www.cnblogs.com/moon-yyl/p/11620833.html