element-ui中下拉框可输入常用得有两种方法
1.@blur方法:输入内容会去匹配选择项,没匹配中清空输入框
<el-form-item :label="firstClsf" prop="firstClsf">
<el-select
style="width:100%"
v-model="caseList.firstClsf"
@blur="selectBlur"
clearable
filterable
>
<el-option
v-for="item in firstClsfGroups"
:label="item.groupName"
:key="item.id"
:value="item.id"
></el-option>
</el-select>
</el-form-item>
methods:{
selectBlur(e){
this.caseList.firstClsf = e.target.value
}
}
- allow-create配置项:输入内容优先匹配项,没匹配到会创建输入得项
<el-form-item :label="firstClsf" prop="firstClsf">
<el-select
style="width:100%"
v-model="caseList.firstClsf"
allow-create
clearable
filterable
>
<el-option
v-for="item in firstClsfGroups"
:label="item.groupName"
:key="item.id"
:value="item.id"
></el-option>
</el-select>
</el-form-item>