vue2项目请移步@94ai/common-ui
LLMs.md

nf-popup-lazy-select ​

把异步分页选择器放到 Popover 中,支持自定义触发区域、是否赋值、选中后关闭、完整对象回调和手动控制浮层。

示例 ​

多选&单选&收起&赋值 ​

正在加载示例…
多选&单选&收起&赋值

回显 ​

正在加载示例…
回显

属性 ​

说明沿用 common-ui 的业务含义,默认值和签名以当前 Vue 3 实现为准。兼容属性不等于已启用旧渲染能力。

属性说明类型可选值默认值
modelValue / v-model (value)绑定值;兼容 value,Vue 3 推荐 v-modelSelectModelValue—undefined
tag定制渲染标签,div 或 custom-select-dropdown 可内联展示列表string | Component—'custom-select-dropdown'
popdownOnSelect单选时选中是否关闭浮层boolean—false
assignmentOnSelect选中是否更新绑定值;false 时仍通知点击项boolean—true
emitSelectedItemOnClickget-selected-data 默认返回值;true 时返回完整数据项boolean—false
visibleChangeKeywordCached失焦后保留搜索关键词boolean—true
visibleChangeSelectListCached失焦后保留搜索结果列表boolean—true
keyValue数据项 label 和 value 对应的字段名[string, string]—['label', 'value']
virtualList是否启用虚拟滚动boolean—false
dataKey虚拟列表每项的唯一键,支持字段名或函数string | ((row: SelectOption) => string | number)—'templateId'
itemOptions集中配置列表属性与 events,事件名支持短横线与驼峰写法Record<string, unknown>—{}
dataComponent自定义选项组件,接收 source、index 和 extraPropsComponent—undefined
estimateSize每行估计高度,单位 pxnumber—34
keeps内联虚拟列表最小渲染数量;下拉使用 SelectV2 的虚拟化number—30
request分页请求方法,返回 records 和记录总数 total;入参及上下文见下方接口LazySelectRequest—undefined
initList初始化时加载数据;false 时延迟到 focusboolean—true
pageSize每次分页请求数量number—10
keywordAlias请求中搜索关键词的字段名string—'keyword'
pageNoAlias请求中页码的字段名string—'pageNo'
pageSizeAlias请求中页大小的字段名string—'pageSize'
valueAlias首次回显请求中已选值的字段名string—'value'
loadingDesc加载中显示的文字string—跟随语言配置
height列表滚动区域高度string—'245px'
width选择器宽度string—'100%'
maxWidth选择器最大宽度string—undefined
showTip是否显示选项 tooltipboolean—true
multiple是否多选boolean—false
disabled是否禁用boolean—继承配置
size输入框尺寸,mini / medium 兼容映射为 small / defaultSelectSizesmall / default / large / mini / medium'mini'
collapseTags多选时是否合并展示选中标签boolean—multiple
multipleLimit多选上限,0 表示不限制number—0
placeholder输入框占位文本string—跟随语言配置
noDataText无选项时的文本,也可使用 empty 插槽string—跟随语言配置
popperClass下拉框的类名string—undefined
start内联列表初始滚动索引number—0
offset内联列表初始滚动偏移,单位 pxnumber—0
direction兼容字段,当前不生效Stringverticalundefined
pageMode兼容字段,当前不生效boolean—undefined
topThreshold触发 totop 的顶部阈值,可能重复触发number—0
bottomThreshold触发 tobottom 的底部阈值,可能重复触发number—0
rootTag内联列表根标签String—'div'
wrapTag内联列表容器标签String—'div'
wrapClass兼容字段,当前不生效String—undefined
wrapStyle内联列表容器样式CSSProperties—undefined
itemTag内联列表行容器标签String—'div'
itemClass内联列表行类名String—undefined
itemClassAdd额外行类名函数 (index, row)(index: number, row: SelectOption) => string—undefined
itemStyle内联列表行样式CSSProperties—undefined
itemScopedSlots兼容字段,当前不生效Object—undefined
headerTag兼容字段,当前不生效String—undefined
headerClass兼容字段,当前不生效String—undefined
headerStyle兼容字段,当前不生效CSSProperties—undefined
footerTag兼容字段,当前不生效String—undefined
footerClass兼容字段,当前不生效String—undefined
footerStyle兼容字段,当前不生效CSSProperties—undefined
options选择项列表SelectOption[]—[]
selectAll是否显示全选控件boolean—false
selectAllText全选控件显示的文字string—跟随语言配置
clearable是否可以清空选项boolean—true
reserveKeyword选中后是否保留当前搜索关键词boolean—true
filterable是否可搜索boolean—true
filterMethod自定义搜索方法(query: string) => void | Promise<void>—undefined
remote是否由远程方法处理搜索boolean—false
loading是否正在加载boolean—false
popperAppendToBody是否将弹层传送到 body,对应 Element Plus teleportedboolean—true
defaultFirstOption回车时默认选中首个匹配项boolean—false
allowCreate允许创建新条目,需配合 filterableboolean—false
automaticDropdown不可搜索时,获得焦点是否自动展开boolean—false
name输入框原生 namestring—undefined
keywordHighlight是否高亮搜索关键词boolean—true
keywordLabelAlias保留兼容字段;高亮使用文本节点,不注入 HTMLstring—'keywordHighlightLabel'
echoValueTop虚拟列表将选中项置顶boolean—true
extraProps传给自定义选项组件的额外属性Record<string, unknown>—undefined
headeClass兼容字段,当前不生效string—undefined
beforeVisibleChange展开/收起后的处理钩子;返回 break 跳过后续内部处理(visible: boolean) => void | "break" | "discard-cache" | Promise<void | "break" | "discard-cache">—undefined
placement下拉框位置SelectProps["placement"]—undefined
initListAssigmentValue兼容属性,当前不会用首批数据覆盖绑定值boolean—false
noDataImg无数据时展示 NfEmptyboolean—false
allowEmptySearch允许未输入关键词时发起搜索请求boolean—true
popupWidth浮层宽度number | string—200
popupClass浮层类名string—undefined
popupTitle浮层标题string—undefined
popupDisabled是否禁用浮层boolean—false
popupOffset浮层偏移量number—0
popupPlacement浮层位置PopoverProps["placement"]—'bottom'
popupTrigger浮层触发方式stringclick / hover / focus / manual'click'
popupTransition浮层过渡动画名称string—undefined
popupVisibleArrow是否显示浮层箭头boolean—true
popupOptions传给 Popper 的选项object—undefined
popupOpenDelay浮层打开延迟,单位 msnumber—undefined
popupCloseDelay浮层关闭延迟,单位 msnumber—200
popupTabindex浮层触发元素 tabindexnumber—0

request(params, context) 可返回同步结果或 Promise。params 按上述别名传递页码、页大小和关键词,首次回显还包含已选值(包括 0 / false)。context.data 为当前标准化列表,originData 为当前原始记录,allCachedDataList 为实例累计缓存。返回 total 是记录总数,不是总页数。fetch-data 的 current 为当前页;records 为本次原始记录,data 为累计标准化列表,originData 为累计原始记录。

ts
type RequestParams = Record<string, string | number | boolean | (string | number | boolean)[] | undefined>
interface RequestContext {
  data: SelectOption[]
  originData: SelectOption[]
  allCachedDataList: SelectOption[]
}
type RequestResult = { records: SelectOption[]; total: number }
type LazySelectRequest = (params: RequestParams, context: RequestContext) => RequestResult | Promise<RequestResult>
interface FetchCallBackData {
  total: number
  current: number
  hasMore: boolean
  keyword: string
  records: SelectOption[]
  data: SelectOption[]
  originData: SelectOption[]
  allCachedDataList: SelectOption[]
}

事件 ​

事件说明参数
update:modelValue选中值变化,更新 v-model(value: SelectModelValue)
update:value选中值变化,保留旧版事件(value: SelectModelValue)
input选中值变化,保留旧版事件(value: SelectModelValue)
change选中值发生变化时触发(value: SelectModelValue)
focus输入框获得焦点时触发(event: FocusEvent)
blur输入框失去焦点时触发(event: FocusEvent)
clear点击清空控件时触发()
remove-tag多选模式下移除标签时触发(value: SelectValue)
visible-change下拉框出现为 true,隐藏为 false(visible: boolean)
select-item点击选项,返回该项的 value(value: SelectValue)
scroll列表滚动;参数仅为 Event,不再附带旧 range(event: Event)
totop列表滚动到顶部阈值时触发(event?: Event)
tobottom列表滚动到底部阈值时触发(event?: Event)
resized列表视口尺寸测量通知(id: string | number, size: number)
fetch-data每次请求成功后触发(data: FetchCallBackData)
fetch-error请求失败时触发(error: unknown)
get-selected-data选中值变化;由 emitSelectedItemOnClick 决定返回值或完整数据项(valueOrRows: SelectModelValue | SelectOption | (SelectOption | undefined)[])
popup-show浮层开始显示,参数为 true(visible: true)
popup-hide浮层开始隐藏,参数为 false(visible: false)
popup-after-enter浮层显示动画完成,无参数()
popup-after-leave浮层隐藏动画完成,无参数()

插槽 ​

插槽说明作用域
default触发浮层的参考元素—
option自定义每个选项{ row: SelectOption, item: SelectOption, index: number }
header列表顶部内容—
footer列表底部内容—
prefix输入框前缀内容—
empty无选项时的内容—
loading自定义加载状态—
tag自定义多选标签Element Plus tag slot props

实例方法与状态 ​

  • currentVal
  • popup
  • popLazySelectRef
  • dataList
  • dataMap
  • allCachedDataList

迁移说明 ​

assignmentOnSelect=false 时不写入 v-model,仍通过 get-selected-data 返回点击值/对象。popdownOnSelect 对值 0/false 同样生效。默认 tag="custom-select-dropdown" 为新的内联列表,不再复制 Element UI Select 的内部实现。弹层参数映射到 Element Plus Popover,手动控制使用实例 popup。

request(params, context) returns { records, total }. Stale requests cannot overwrite the current search. fetch-error reports failures; retry the same page. allCachedDataMap / dataMap are typed Maps.