数组过滤,element-ui的select下拉选项,公司员工加入一个角色,已经添加过的不能再添加,
文章目录
html结构
//遍历optionsList看每一项的值在quNameList数组中有没有,如果有,则不显示
<el-select v-model="addForm.repositoryType" size="small" clearable placeholder="请选择" >
<el-option v-for="item in optionsList" :key="item.value" :label="item.label" :value="item.value"
v-if="quNameList.indexOf(item.value) == -1" > </el-option>
</el-select>
methods 方法中
this.quNameList = []
//this.rowData.children 已经添加到角色中的员工列表,
//遍历这个列表,取出列表中的值(name,或id)添加到quNameList数组中
let children = this.rowData.children
children.map(item=>{
this.quNameList.push(item.repositoryType)
})
评论
登录后参与技术讨论,分享你的经验与见解。
登录 / 注册暂无评论