Skip to content

AutoComplete 自动完成

基本用法

ts
import '@company-ui/style';
import { Autocomplete } from '@company-ui/dom';

new Autocomplete({
  target: '#autocomplete1',
  placeholder: 'Input company name',
});

其他数据源用法

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',
});

API

Attributes

NameDescriptionTypeDefault
targetHTML元素标签的idstring-
api查询数据源stringclearbit
queryDelay查询数据延迟number500
placeholder输入占位符内容stringInput company name
clearable显示清除按钮booleantrue
backFill使用键盘选择选项的时候把选中项回填到输入框中booleantrue
popupAppendToBody是否插入至 body 元素上booleantrue
autoFocus自动获取焦点booleantrue
showSubmitButton显示提交按钮booleantrue
submitButtonLabel提交按钮文字stringSubmit
offsetTop距离文本框底部的偏移值number5
autoFlip文本框是否自动翻转booleanfalse
avatarUrl头像链接string-
clearIcon清除按钮图标string
history历史记录配置HistoryOptionsHistoryOptions

HistoryOptions

NameDescriptionTypeDefault
enabled打开保存历史记录booleantrue
type保存历史记录模式stringlocalStorage
key保存历史记录键stringcompany-history
showClear显示历史记录清除按钮booleantrue
itemIcon历史记录图标string
clearIcon清除历史记录按钮图标string

Events

NameDescriptionType
onInput当输入值改变时触发Function
onChange当输入值改变时触发Function
onFetch查询数据时触发Function
onAbortFetch当中止查询数据时触发Function
onSelect当单击建议时触发Function
onClear当单击文本框清除按钮时触发Function
onFocus当输入聚焦时触发Function
onBlur当输入取消聚焦时触发Function
submitCallback按钮提交时触发Function
onDropdownVisibleChange当下拉菜单出现/消失时触发Function

本中文文档内容版权为 Michael Sun 所有,保留所有权利。