使用vue-选择,我正在搜索一种增加输入延迟的方法,以便在用户暂停输入(例如500 is )之后发送ajax搜索请求。
我怎么才能把这个存档?在文档中,我找不到任何选项。
在我的解决方案中,我有一个定制的ajax过滤器:
<vSelect
class="my-select"
@search="fetchOptions"
:filterable="false"
:options="options"
label="name"
v-model="selectedVal"
:disabled="disabled"
:reduce="(result) => result.id"
>发布于 2022-03-16 09:54:20
我想出了添加lodash.debouncer的方法。出于兴趣,遵循我的解决方案:
<vSelect
class="my-select"
@search="loadDebouncer"
:filterable="false"
:options="options"
label="myLabel"
v-model="selectedVal"
:disabled="disabled"
>import { Component, Vue, Prop, Watch } from 'vue-property-decorator';
import debounce from 'lodash.debounce';
@Component
export default class MySelect extends Vue{
public loadDebouncer = debounce((searchString, loading) => this.fetchOptions(searchString, loading), 500);
public async fetchOptions(searchString: string, loading:any){
//Load my list
}
}https://stackoverflow.com/questions/71494315
复制相似问题