修复 search-method 自定义搜索逻辑不生效
This commit is contained in:
parent
0c0d4d19f3
commit
ad047574b4
@ -60,14 +60,13 @@ const selected = computed(() => {
|
||||
}
|
||||
});
|
||||
|
||||
// 首次加载, 不启用 search-method 方法。
|
||||
const isFirst = ref(true);
|
||||
const first = ref(true);
|
||||
|
||||
const display = computed(() => {
|
||||
if (searchMethod && !isFirst.value) {
|
||||
isFirst.value = false;
|
||||
if (searchMethod && !first.value) {
|
||||
return searchMethod(searchValue.value, props);
|
||||
}
|
||||
first.value = false;
|
||||
return (
|
||||
props.keyword?.toString().indexOf(searchValue.value) > -1 ||
|
||||
props.label?.toString().indexOf(searchValue.value) > -1
|
||||
|
@ -122,7 +122,7 @@ export default {
|
||||
<lay-select-option value="2" label="编码"></lay-select-option>
|
||||
<lay-select-option value="3" label="运动"></lay-select-option>
|
||||
</lay-select>
|
||||
<lay-select v-model="value4" :show-search="true" :multiple="true">
|
||||
<lay-select v-model="value4" :show-search="true" :multiple="true" :search-method="searchMethod">
|
||||
<lay-select-option value="1" label="学习"></lay-select-option>
|
||||
<lay-select-option value="2" label="编码"></lay-select-option>
|
||||
<lay-select-option value="3" label="运动"></lay-select-option>
|
||||
@ -138,10 +138,15 @@ export default {
|
||||
|
||||
const value3 = ref('1')
|
||||
const value4 = ref(['1'])
|
||||
|
||||
const searchMethod = (text, props) => {
|
||||
return props.label.indexOf(text) != -1;
|
||||
}
|
||||
|
||||
return {
|
||||
value3,
|
||||
value4
|
||||
value4,
|
||||
searchMethod
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -207,9 +212,10 @@ export default {
|
||||
|
||||
const value3 = ref('1')
|
||||
const value4 = ref(['1'])
|
||||
|
||||
return {
|
||||
value3,
|
||||
value4
|
||||
value4,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user