最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Vue實(shí)現(xiàn)穿梭框效果

 更新時(shí)間:2020年09月30日 08:46:53   作者:知我未夠好丶  
這篇文章主要為大家詳細(xì)介紹了Vue實(shí)現(xiàn)穿梭框效果,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

用vue實(shí)現(xiàn)的穿梭框,實(shí)現(xiàn)基本的功能(數(shù)據(jù)移動(dòng)、全選、反選、搜索)。

代碼:

<!DOCTYPE html>
<html>
 <head>
 <meta charset="utf-8">
 <title>穿梭框</title>
  <script src="./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)" class="to"/>
    <input type="button" value="<" @click="change_type(1)" class="to"/>
   </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}}項(xiàng)
     </div>
     <input type="text" placeholder="搜索" @keyup="change_search_word" class="search"/>
     <ul class="contents">
      <li class="content" 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>

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • Vue3中的組件數(shù)據(jù)懶加載

    Vue3中的組件數(shù)據(jù)懶加載

    這篇文章主要介紹了Vue3中的組件數(shù)據(jù)懶加載問題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2023-10-10
  • vue中可編輯樹狀表格的實(shí)現(xiàn)代碼

    vue中可編輯樹狀表格的實(shí)現(xiàn)代碼

    這篇文章主要介紹了vue中可編輯樹狀表格的實(shí)現(xiàn)代碼,本文通過實(shí)例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2020-10-10
  • vue中swiper開啟loop后,點(diǎn)擊事件不響應(yīng)的解決方案

    vue中swiper開啟loop后,點(diǎn)擊事件不響應(yīng)的解決方案

    這篇文章主要介紹了vue中swiper開啟loop后,點(diǎn)擊事件不響應(yīng)的解決方案,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2022-09-09
  • vue實(shí)現(xiàn)動(dòng)態(tài)控制表格列的顯示隱藏

    vue實(shí)現(xiàn)動(dòng)態(tài)控制表格列的顯示隱藏

    這篇文章主要為大家詳細(xì)介紹了vue實(shí)現(xiàn)動(dòng)態(tài)控制表格列的顯示隱藏,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2022-04-04
  • vue使用pdf.js預(yù)覽pdf文件的方法

    vue使用pdf.js預(yù)覽pdf文件的方法

    在頁面進(jìn)行pdf預(yù)覽的時(shí)候,由于文件不能夠打印和下載很難滿足客戶的需求,接下來通過本文給大家介紹vue使用pdf.js來進(jìn)行pdf預(yù)覽,需要的朋友可以參考下
    2021-12-12
  • 詳解Vue的watch中的immediate與watch是什么意思

    詳解Vue的watch中的immediate與watch是什么意思

    這篇文章主要介紹了詳解Vue的watch中的immediate與watch是什么意思,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2019-12-12
  • vue computed計(jì)算屬性顯示undefined的解決

    vue computed計(jì)算屬性顯示undefined的解決

    這篇文章主要介紹了vue computed計(jì)算屬性顯示undefined的解決方案,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2023-11-11
  • Vue+webpack實(shí)現(xiàn)懶加載過程解析

    Vue+webpack實(shí)現(xiàn)懶加載過程解析

    這篇文章主要介紹了Vue+webpack實(shí)現(xiàn)懶加載過程解析,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下
    2020-02-02
  • vue實(shí)現(xiàn)鼠標(biāo)移入移出事件代碼實(shí)例

    vue實(shí)現(xiàn)鼠標(biāo)移入移出事件代碼實(shí)例

    這篇文章主要介紹了vue實(shí)現(xiàn)鼠標(biāo)移入移出事件,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2019-03-03
  • Vue3根據(jù)動(dòng)態(tài)字段綁定v-model的操作代碼

    Vue3根據(jù)動(dòng)態(tài)字段綁定v-model的操作代碼

    最近在學(xué)習(xí)vue技術(shù),開發(fā)表格的時(shí)候,想把表格做成組件,那查詢條件就需要?jiǎng)討B(tài)生成,這就遇到一個(gè)問題,vue怎么動(dòng)態(tài)給v-model變量值,本文通過實(shí)例代碼給大家介紹,對(duì)Vue3動(dòng)態(tài)綁定v-model實(shí)例代碼感興趣的朋友一起看看吧
    2022-10-10

最新評(píng)論

镇巴县| 绵竹市| 朝阳市| 沂南县| 佛冈县| 南昌县| 花莲市| 遂昌县| 曲阳县| 长宁县| 阿坝县| 安陆市| 呈贡县| 黎平县| 岱山县| 嘉峪关市| 长寿区| 诸暨市| 宝山区| 垫江县| 西平县| 安远县| 内乡县| 昌乐县| 明光市| 高密市| 隆尧县| 封开县| 安顺市| 嫩江县| 温州市| 陇西县| 永德县| 泰州市| 三原县| 石棉县| 都安| 诸城市| 兴安县| 孙吴县| 封丘县|