色综合图-色综合图片-色综合图片二区150p-色综合图区-玖玖国产精品视频-玖玖香蕉视频

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

Vue實現穿梭框效果

瀏覽:75日期:2022-11-17 15:49:52

用vue實現的穿梭框,實現基本的功能(數據移動、全選、反選、搜索)。

Vue實現穿梭框效果

代碼:

<!DOCTYPE html><html> <head> <meta charset='utf-8'> <title>穿梭框</title> <script src='http://www.lshqa.cn/bcjs/js/vue.js' type='text/javascript' charset='utf-8'></script> <style type='text/css'> * { margin: 0; padding: 0; } #transfer { width: 388px; height: 218px; border: gray solid 1px; display: flex; } .container { margin: 10px; width: 150px; height: 200px; } #btns { width: 50px; height: 60px; margin: auto; } .to { margin: 0 10px 10px 10px; width: 30px; } .search { width: 140px; outline: 0; margin: 10px 0; } .content { list-style: none; margin-bottom: 10px; } </style> </head> <body> <div id='transfer'> <container :datas='contents' :type='0'></container> <div id='btns'> <input type='button' value='>' @click='change_type(0)' /> <input type='button' value='<' @click='change_type(1)' /> </div> <container :datas='contents' :type='1'></container> </div> <script type='text/javascript'> Vue.component(’container’, { props: [’datas’, ’type’], data() { return { search_word: ’’ } }, template: ` <div class='container'> <div class='top'> <input type='checkbox' name='all' @click='all' :checked='filter_chosen === filter && filter'/> <span v-show='filter_chosen'>{{filter_chosen}}/</span>{{filter_search_word}}項 </div> <input type='text' placeholder='搜索' @keyup='change_search_word' /> <ul class='contents'> <li v-for='(content, idx) in datas' v-show='content.type === type && has_search_word(content.content)'> <input type='checkbox' @click='change(idx)' :checked='content.chosen'/>{{content.content}} </li> </ul> </div>`, methods: { change(idx) { this.datas[idx].chosen = !this.datas[idx].chosen; }, all() { this.change_chosen(!(this.filter_chosen === this.filter)); }, change_chosen(bool) { this.datas.map(x => { if (x.type === this.type ) {x.chosen = bool; } }); }, change_search_word(e) { this.search_word = e.target.value; }, has_search_word(content) { if (this.search_word) { return content.includes(this.search_word); } return true; } }, computed: { filter() { return this.datas.filter(x => x.type === this.type).length; }, filter_chosen() { return this.datas.filter(x => x.type === this.type && x.chosen).length; }, filter_search_word() { return this.datas.filter(x => x.type === this.type && this.has_search_word(x.content)).length; } } }); new Vue({ el: ’#transfer’, data: { contents: [ { content: ’a’, type: 0, chosen: false }, { content: ’b’, type: 0, chosen: false }, { content: ’c’, type: 0, chosen: false }, { content: ’d’, type: 0, chosen: false }, ] }, methods: { change_type(type) { for (content of this.$data.contents) { if (content.chosen && content.type === type) {content.chosen = false;content.type = Number(!type); } } } } }) </script> </body></html>

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

標簽: Vue
相關文章:
主站蜘蛛池模板: 成人偷拍视频 | 成人久久影院 | 在线免费看一级片 | 国产精品国产三级在线高清观看 | 99久久精品国产片 | 午夜视频在线观看一区 | 免费看国产精品久久久久 | 老司机成人免费精品视频 | 精品视频网 | 免费一级欧美片片线观看 | 亚洲在线视频网站 | 成人一a毛片免费视频 | 免费一级毛片在播放视频 | 99久久免费视频在线观看 | 日韩一区二区不卡 | 国产精品黄页网站在线播放免费 | 国产日韩欧美swag在线观看 | 欧美人成在线观看网站高清 | 国产成人免费高清在线观看 | 亚洲成人欧美 | 欧美视频在线观看网站 | 色老头久久久久 | 精品一区二区三区在线播放 | 国产一区私人高清影院 | 怡红院成人永久免费看 | 在线成人免费视频 | 久久久亚洲精品国产 | 国产在线欧美日韩一区二区 | 九九热爱视频精品视频高清 | 国产成人18黄网站在线观看网站 | 久久久久免费视频 | 欧美一级欧美一级毛片 | 黄色毛片在线 | 国产在线更新 | 亚洲一区二区三区影院 | 国产成人禁片免费观看 | 一级特黄一欧美俄罗斯毛片 | 亚洲视频免费在线看 | 国产jk福利视频在线观看 | 亚洲精品欧美精品中文字幕 | 日韩欧美三级在线观看 |