mirror of
https://gitee.com/element-plus/element-plus.git
synced 2024-12-05 04:37:47 +08:00
refactor(components): [select] use util function (#10286)
This commit is contained in:
parent
c5aa563bc7
commit
874aa0a284
@ -22,6 +22,8 @@ import {
|
||||
getComponentSize,
|
||||
isFunction,
|
||||
isKorean,
|
||||
isNumber,
|
||||
isString,
|
||||
scrollIntoView,
|
||||
} from '@element-plus/utils'
|
||||
import {
|
||||
@ -347,7 +349,7 @@ export const useSelect = (props, states: States, ctx) => {
|
||||
watch(
|
||||
() => states.hoverIndex,
|
||||
(val) => {
|
||||
if (typeof val === 'number' && val > -1) {
|
||||
if (isNumber(val) && val > -1) {
|
||||
hoverOption.value = optionsArray.value[val] || {}
|
||||
} else {
|
||||
hoverOption.value = {}
|
||||
@ -393,8 +395,7 @@ export const useSelect = (props, states: States, ctx) => {
|
||||
if (states.previousQuery === val || states.isOnComposition) return
|
||||
if (
|
||||
states.previousQuery === null &&
|
||||
(typeof props.filterMethod === 'function' ||
|
||||
typeof props.remoteMethod === 'function')
|
||||
(isFunction(props.filterMethod) || isFunction(props.remoteMethod))
|
||||
) {
|
||||
states.previousQuery = val
|
||||
return
|
||||
@ -412,10 +413,10 @@ export const useSelect = (props, states: States, ctx) => {
|
||||
resetInputHeight()
|
||||
})
|
||||
}
|
||||
if (props.remote && typeof props.remoteMethod === 'function') {
|
||||
if (props.remote && isFunction(props.remoteMethod)) {
|
||||
states.hoverIndex = -1
|
||||
props.remoteMethod(val)
|
||||
} else if (typeof props.filterMethod === 'function') {
|
||||
} else if (isFunction(props.filterMethod)) {
|
||||
props.filterMethod(val)
|
||||
triggerRef(groupQueryChange)
|
||||
} else {
|
||||
@ -612,7 +613,7 @@ export const useSelect = (props, states: States, ctx) => {
|
||||
const deleteSelected = (event) => {
|
||||
event.stopPropagation()
|
||||
const value: string | any[] = props.multiple ? [] : ''
|
||||
if (typeof value !== 'string') {
|
||||
if (!isString(value)) {
|
||||
for (const item of states.selected) {
|
||||
if (item.isDisabled) value.push(item.value)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user