<el-select
v-model="data.basic.pack"
ref="refPack"
filterable
remote
@change="select"
allow-create
:remote-method="handleFetchPackList"
>
<el-option
v-for="item in options.package"
:key="item.code"
:label="item.name"
:value="item.code"
/>
</el-select>
希望通过allow-create创建之后,监听被创建的值,因为需要调接口把这个值插入数据库,google了一下说是可以通过refPack.value.createdLabel
这个方法获取,但是获取到的始终是undefined.
只能在change里监听值,判断是否在v-for循环的数组里,这样去判断吗? 但是这个select又是可以远程搜索的,又可能有大坑...
最好的方法是后端给你一个查询接口,onchange 之后你就查询下它属不属于你的下拉列表。最好不要用组件库中文档中没提到的字段/功能,因为你不能保证它的下一个版本是否还保留这种写法。