AutoComplete
Basic Usage
ts
import '@company-ui/style';
import { Autocomplete } from '@company-ui/dom';
new Autocomplete({
target: '#autocomplete1',
});Data Source Usage
ts
import '@company-ui/style';
import { Autocomplete } from '@company-ui/dom';
new Autocomplete({
api: 'qcc_open',
target: '#autocomplete2',
autoFocus: false,
submitButtonLabel: '查一查',
historyStorageKey: 'qcc-open-company-history',
placeholder: '请输入企业名称或统一社会信用代码',
});API
Attributes
| Name | Description | Type | Default |
|---|---|---|---|
| target | id of the html element tag | string | - |
| api | query data source | string | clearbit |
| queryDelay | query data delay | number | 500 |
| placeholder | input placeholder content | string | Input company name |
| clearable | show clear button | boolean | true |
| backFill | If backFill selected item the input when using keyboard | boolean | true |
| popupAppendToBody | whether to append Dialog itself to body | boolean | true |
| autoFocus | auto focus | boolean | true |
| showSubmitButton | show submit button | boolean | true |
| submitButtonLabel | submit button label | string | Submit |
| offsetTop | pixels to offset from input bottom | number | 5 |
| autoFlip | auto flip | boolean | false |
| avatarUrl | avatar url | string | - |
| clearIcon | clear icon | string | |
| history | history options | HistoryOptions | HistoryOptions |
HistoryOptions
| Name | Description | Type | Default |
|---|---|---|---|
| enabled | history enabled | boolean | true |
| type | history save mode | string | localStorage |
| key | history save key | string | company-history |
| showClear | show clear history link | boolean | true |
| itemIcon | history item icon | string | |
| clearIcon | clear history link icon | string |
Events
| Name | Description | Type |
|---|---|---|
| onInput | triggers when the input value change | Function |
| onChange | triggers when the input value change | Function |
| onFetch | triggers when query data | Function |
| onAbortFetch | triggers when abort query data | Function |
| onSelect | triggers when a suggestion is clicked | Function |
| onClear | triggers when the input is cleared by clicking the clear button | Function |
| onFocus | triggers when the input focuses | Function |
| onBlur | triggers when the input blurs | Function |
| onSubmit | triggers when the button submit | Function |
| onDropdownVisibleChange | triggers when the dropdown appears/disappears | Function |
