怎么在vue中添加標(biāo)簽demo-創(chuàng)新互聯(lián)

本篇文章給大家分享的是有關(guān)怎么在vue中添加標(biāo)簽demo,小編覺(jué)得挺實(shí)用的,因此分享給大家學(xué)習(xí),希望大家閱讀完這篇文章后可以有所收獲,話不多說(shuō),跟著小編一起來(lái)看看吧。

創(chuàng)新互聯(lián)建站公司2013年成立,先為平塘等服務(wù)建站,平塘等地企業(yè),進(jìn)行企業(yè)商務(wù)咨詢服務(wù)。為平塘企業(yè)網(wǎng)站制作PC+手機(jī)+微官網(wǎng)三網(wǎng)同步一站式服務(wù)解決您的所有建站問(wèn)題。

html

<div id="app">
<div >
  <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:'開(kāi)發(fā)語(yǔ)法'}, {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});
      }
    }
  });

以上就是怎么在vue中添加標(biāo)簽demo,小編相信有部分知識(shí)點(diǎn)可能是我們?nèi)粘9ぷ鲿?huì)見(jiàn)到或用到的。希望你能通過(guò)這篇文章學(xué)到更多知識(shí)。更多詳情敬請(qǐng)關(guān)注創(chuàng)新互聯(lián)網(wǎng)站建設(shè)公司行業(yè)資訊頻道。

另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)建站muchs.cn,海內(nèi)外云服務(wù)器15元起步,三天無(wú)理由+7*72小時(shí)售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國(guó)服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡(jiǎn)單易用、服務(wù)可用性高、性價(jià)比高”等特點(diǎn)與優(yōu)勢(shì),專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場(chǎng)景需求。

標(biāo)題名稱:怎么在vue中添加標(biāo)簽demo-創(chuàng)新互聯(lián)
當(dāng)前鏈接:http://muchs.cn/article26/hicjg.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供面包屑導(dǎo)航企業(yè)建站、品牌網(wǎng)站建設(shè)、網(wǎng)站建設(shè)、域名注冊(cè)網(wǎng)站策劃

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

外貿(mào)網(wǎng)站制作