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

萬全網(wǎng)站制作公司哪家好,找成都創(chuàng)新互聯(lián)公司!從網(wǎng)頁設(shè)計、網(wǎng)站建設(shè)、微信開發(fā)、APP開發(fā)、自適應(yīng)網(wǎng)站建設(shè)等網(wǎng)站項目制作,到程序開發(fā),運營維護。成都創(chuàng)新互聯(lián)公司2013年開創(chuàng)至今到現(xiàn)在10年的時間,我們擁有了豐富的建站經(jīng)驗和運維經(jīng)驗,來保證我們的工作的順利進行。專注于網(wǎng)站建設(shè)就選成都創(chuàng)新互聯(liá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:'開發(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});
}
}
});以上就是怎么在vue中添加標(biāo)簽demo,小編相信有部分知識點可能是我們?nèi)粘9ぷ鲿姷交蛴玫降摹OM隳芡ㄟ^這篇文章學(xué)到更多知識。更多詳情敬請關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道。
文章標(biāo)題:怎么在vue中添加標(biāo)簽demo
網(wǎng)址分享:http://www.chinadenli.net/article12/pgshdc.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供虛擬主機、外貿(mào)網(wǎng)站建設(shè)、動態(tài)網(wǎng)站、軟件開發(fā)、品牌網(wǎng)站設(shè)計、網(wǎng)站導(dǎo)航
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)