您好,登錄后才能下訂單哦!
小編給大家分享一下vue中如何實現(xiàn)動態(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 不能重復(fù)選擇相同的數(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中如何實現(xiàn)動態(tài)循環(huán)出多個select出現(xiàn)過的變?yōu)閐isabled”有了一定的了解,如果想了解更多相關(guān)知識,歡迎關(guān)注億速云行業(yè)資訊頻道,感謝各位的閱讀!
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。