feat(auto-complete): add onUpdateValue prop (#999)

This commit is contained in:
Yugang Cao 2021-08-27 23:56:43 +08:00 committed by GitHub
parent 376a88988d
commit a018945240
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 2 deletions

View File

@ -1,5 +1,11 @@
# CHANGELOG
## Pending
### Feats
- `n-auto-complete` add `onUpdateValue` prop.
## 2.16.7 (2021-08-27)
### Feats

View File

@ -1,5 +1,11 @@
# CHANGELOG
## Pending
### Feats
- `n-auto-complete` 新增 `onUpdateValue` 方法
## 2.16.7 (2021-08-27)
### Feats

View File

@ -76,8 +76,8 @@ const autoCompleteProps = {
default: () => []
},
zIndex: Number,
// eslint-disable-next-line vue/prop-name-casing
'onUpdate:value': [Function, Array] as PropType<MaybeArray<OnUpdateValue>>,
onUpdateValue: [Function, Array] as PropType<MaybeArray<OnUpdateValue>>,
onSelect: [Function, Array] as PropType<MaybeArray<OnSelect>>,
onBlur: [Function, Array] as PropType<MaybeArray<(e: FocusEvent) => void>>,
onFocus: [Function, Array] as PropType<MaybeArray<(e: FocusEvent) => void>>,
@ -144,9 +144,10 @@ export default defineComponent({
)
)
function doUpdateValue (value: string | null): void {
const { 'onUpdate:value': onUpdateValue, onInput } = props
const { 'onUpdate:value': _onUpdateValue, onUpdateValue, onInput } = props
const { nTriggerFormInput, nTriggerFormChange } = formItem
if (onUpdateValue) call(onUpdateValue as OnUpdateImpl, value)
if (_onUpdateValue) call(_onUpdateValue as OnUpdateImpl, value)
if (onInput) call(onInput as OnUpdateImpl, value)
uncontrolledValueRef.value = value
nTriggerFormInput()