vue動態(tài)循環(huán)出的多個select出現(xiàn)過的變?yōu)閐isabled(實例代碼)
更新時間:2019年11月10日 08:07:19 作者:zaijinyang
本文通過實例代碼給大家分享了vue動態(tài)循環(huán)出的多個select出現(xiàn)過的變?yōu)閐isabled效果,非常不錯,具有一定的參考借鑒價值,需要的朋友參考下吧
vue動態(tài)循環(huán)出的多個select出現(xiàn)過的變?yōu)閐isabled
<template>
<div class="artcle">
<el-form
label-width="100px"
:model="testForm">
<el-form-item
v-for="(vtem, index) in testForm.version"
:key="index"
label="命令版本">
<el-select
@change="comChange"
v-model="vtem.ver">
<el-option
v-for="item in versionList"
:key="item.id"
:value="item.id"
:disabled="item.id == vtem.ver || selectedArr.includes(item.id)"
:label="item.name">
</el-option>
</el-select>
<el-button
icon="el-icon-circle-plus-outline"
size="small"
@click="add(index)"
circle></el-button>
<el-button
icon="el-icon-remove-outline"
size="small"
@click="remove(index)"
:disabled="index === 0"
circle></el-button>
</el-form-item>
<el-form-item
label="測試輸入框">
<el-input
v-model="testForm.input"></el-input>
</el-form-item>
</el-form>
</div>
</template>
ps:vue 動態(tài)循環(huán)出的多個select 不能重復選擇相同的數(shù)據(jù)
<template>
<div class="program" v-for="(parItem,index) in parArr" :key="parItem.guid">
<Select v-model="parItem.id" @on-change="onChangeProgram">
<Option v-for="(subItem,idx) in programList" :key="subItem.id" :data-index='idx'
v-show="parItem.id == subItem.id || !selectIdsArr.includes(subItem.id)"
:value="subItem.id> {{subItem.name}}</Option>
</Select>
</div>
</template>
<script>
export default {
data() {
return {
parArr:[],
selectIdsArr:[],
programList:[{
"id":1,
"name":"選項1"
},{
"id":2,
"name":"選項2"
},{
"id":3,
"name":"選項3"
}],
}
},
methods: {
onChangeProgram() {
this.selectIdsArr = [];
for (const item of this.parArr) {
if (item.id) {
this.selectIdsArr.push(item.id);
}
}
},
},
}
</script>
總結
以上是小編給大家分享的vue動態(tài)循環(huán)出的多個select出現(xiàn)過的變?yōu)閐isabled效果,希望對大家有所幫助!
相關文章
Vue實現(xiàn)輸入框回車發(fā)送和粘貼文本與圖片功能
這篇文章主要為大家詳細介紹了Vue如何實現(xiàn)聊天輸入框回車發(fā)送、粘貼文本(包括HTML)、粘貼圖片等功能,文中的實現(xiàn)方法講解詳細,需要的可以參考一下2022-05-05
Vue 項目中如何使用fullcalendar 時間段選擇插件(類似課程表格)
最近完成一個項目,需要選擇一個會議室,但是最好能夠通過在圖上顯示出該 會議室在某某時間段內已經被預定了,初看這個功能感覺很棘手,仔細分析下實現(xiàn)起來還是挺容易的,下面通過示例代碼講解Vue項目中使用fullcalendar時間段選擇插件,感興趣的朋友一起看看吧2024-07-07
vue-cli項目代理proxyTable配置exclude的方法
今天小編就為大家分享一篇vue-cli項目代理proxyTable配置exclude的方法,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2018-09-09

