mirror of https://github.com/ElemeFE/element
autocomplete: add highlight-first-item prop (#14269)
parent
85a7b02c51
commit
1fd5964b70
|
@ -6,7 +6,8 @@
|
||||||
:fetch-suggestions="querySearch"
|
:fetch-suggestions="querySearch"
|
||||||
:placeholder="placeholder"
|
:placeholder="placeholder"
|
||||||
:trigger-on-focus="false"
|
:trigger-on-focus="false"
|
||||||
@select="handleSelect">
|
@select="handleSelect"
|
||||||
|
highlight-first-item>
|
||||||
<template slot-scope="props">
|
<template slot-scope="props">
|
||||||
<p class="algolia-search-title" v-if="props.item.title">
|
<p class="algolia-search-title" v-if="props.item.title">
|
||||||
<span v-html="props.item.highlightedCompo"></span>
|
<span v-html="props.item.highlightedCompo"></span>
|
||||||
|
|
|
@ -716,6 +716,7 @@ Attribute | Description | Type | Options | Default
|
||||||
| suffix-icon | suffix icon class | string | — | — |
|
| suffix-icon | suffix icon class | string | — | — |
|
||||||
| hide-loading | whether to hide the loading icon in remote search | boolean | — | false |
|
| hide-loading | whether to hide the loading icon in remote search | boolean | — | false |
|
||||||
| popper-append-to-body | whether to append the dropdown to body. If the positioning of the dropdown is wrong, you can try to set this prop to false | boolean | - | true |
|
| popper-append-to-body | whether to append the dropdown to body. If the positioning of the dropdown is wrong, you can try to set this prop to false | boolean | - | true |
|
||||||
|
| highlight-first-item | whether to highlight first item in remote search suggestions by default | boolean | — | false |
|
||||||
|
|
||||||
### Autocomplete Slots
|
### Autocomplete Slots
|
||||||
|
|
||||||
|
|
|
@ -705,6 +705,7 @@ Búsqueda de datos desde el servidor.
|
||||||
| hide-loading | si se debe ocultar el icono de loading en la búsqueda remota | boolean | — | false |
|
| hide-loading | si se debe ocultar el icono de loading en la búsqueda remota | boolean | — | false |
|
||||||
| popper-append-to-body | si añadir el desplegable al cuerpo. Si la posición del menú desplegable es incorrecta, puede intentar establecer este prop a false | boolean | - | true |
|
| popper-append-to-body | si añadir el desplegable al cuerpo. Si la posición del menú desplegable es incorrecta, puede intentar establecer este prop a false | boolean | - | true |
|
||||||
| validate-event | si se debe lanzar la validación de formulario | boolean | - | true |
|
| validate-event | si se debe lanzar la validación de formulario | boolean | - | true |
|
||||||
|
| highlight-first-item | si se debe resaltar el primer elemento en las sugerencias de búsqueda remota de forma predeterminada | boolean | - | false |
|
||||||
|
|
||||||
### Autocomplete Slots
|
### Autocomplete Slots
|
||||||
|
|
||||||
|
|
|
@ -867,6 +867,7 @@ export default {
|
||||||
| suffix-icon | 输入框尾部图标 | string | — | — |
|
| suffix-icon | 输入框尾部图标 | string | — | — |
|
||||||
| hide-loading | 是否隐藏远程加载时的加载图标 | boolean | — | false |
|
| hide-loading | 是否隐藏远程加载时的加载图标 | boolean | — | false |
|
||||||
| popper-append-to-body | 是否将下拉列表插入至 body 元素。在下拉列表的定位出现问题时,可将该属性设置为 false | boolean | - | true |
|
| popper-append-to-body | 是否将下拉列表插入至 body 元素。在下拉列表的定位出现问题时,可将该属性设置为 false | boolean | - | true |
|
||||||
|
| highlight-first-item | 是否默认突出显示远程搜索建议中的第一项 | boolean | — | false |
|
||||||
|
|
||||||
### Autocomplete Slots
|
### Autocomplete Slots
|
||||||
| name | 说明 |
|
| name | 说明 |
|
||||||
|
|
|
@ -126,6 +126,10 @@
|
||||||
popperAppendToBody: {
|
popperAppendToBody: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: true
|
default: true
|
||||||
|
},
|
||||||
|
highlightFirstItem: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
|
@ -176,6 +180,7 @@
|
||||||
}
|
}
|
||||||
if (Array.isArray(suggestions)) {
|
if (Array.isArray(suggestions)) {
|
||||||
this.suggestions = suggestions;
|
this.suggestions = suggestions;
|
||||||
|
this.highlightedIndex = this.highlightFirstItem ? 0 : -1;
|
||||||
} else {
|
} else {
|
||||||
console.error('[Element Error][Autocomplete]autocomplete suggestions must be an array');
|
console.error('[Element Error][Autocomplete]autocomplete suggestions must be an array');
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue