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

vue實(shí)現(xiàn)添加標(biāo)簽demo示例代碼

 更新時(shí)間:2017年01月21日 14:33:08   作者:虎嗅添香  
本篇文章主要介紹了vue實(shí)現(xiàn)添加標(biāo)簽demo示例代碼,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧

本篇文章主要介紹vue添加標(biāo)簽,廢話不多說了,下面上具體代碼

效果如下:

html

<div id="app">
<div style="margin-bottom: 4px;">
  <span class="selectedItem" v-for="item in selectedItems">{{item.name}} <i class="red fa fa-close (alias)"
  v-on:click="deleteSelectedItem($index)"></i></span>
  <input v-model="inputItem" type="text" v-on:focus="showDropmenu" v-on:keyup.enter="addItem">
</div>
<div v-show="isShowDropmenu">
  <button v-for="item in cataName" v-on:click="showCataList($index)">{{item.name}}</button>

  <button v-on:click="hideDropmenu"><i class="red fa fa-close (alias)"></i></button>
  <div v-for="item in cataList" v-show="item.isShow">
    <span v-for="one in item.items" class="item" v-on:click="addByClick(one)">{{one}}</span>
  </div>
</div>
</div>

js

new Vue({
    el:'#app',
    data:{
      selectedItems: [{
        name: 'NodeJs'
      }],
      isShowDropmenu: false,
      inputItem:'',
      cataName:[{name:'開發(fā)語法'}, {name: '系統(tǒng)設(shè)備'}],
      cataList:[{
        isShow: true,
        items:['js','c++','java']
      },{
        isShow: false,
        items:['windows','chrome','linux']
      }]
    },
    methods:{
      showDropmenu: function(event){
        console.log('showDropmenu');
        this.isShowDropmenu = true;
      },
      hideDropmenu: function(event){
        this.isShowDropmenu = false;
        console.log('hideDropmenu');
      },
      test: function(){
        console.log('test');
      },
      addItem: function(){
        this.selectedItems.push({name: this.inputItem});
        this.inputItem = "";
      },
      deleteSelectedItem: function(index){
        this.selectedItems.splice(index, 1);
      },
      showCataList: function(index){
        var i = this.cataList.length;

        while(i--){
          i === index ? this.cataList[i].isShow = true: this.cataList[i].isShow = false;
        }
      },
      addByClick: function(name){

        var i = this.selectedItems.length;
        while(i--){
          if(this.selectedItems[i].name === name){
            return;
          }
        }

        this.selectedItems.push({name: name});
      }
    }
  });

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

相關(guān)文章

最新評論

拉孜县| 松溪县| 祁阳县| 德庆县| 长沙县| 黄浦区| 台南市| 革吉县| 中宁县| 德保县| 长顺县| 鹤岗市| 南投县| 古浪县| 灵川县| 蓬安县| 商水县| 潞城市| 柳州市| 连云港市| 邓州市| 淮安市| 满洲里市| 汾阳市| 安乡县| 通渭县| 新丰县| 财经| 睢宁县| 长沙市| 孟州市| 江口县| 商水县| 合肥市| 武鸣县| 同心县| 大新县| 崇礼县| 晋州市| 偃师市| 衡水市|