From 3eaa653fe8f901c93045ff6f20ce08135bc95297 Mon Sep 17 00:00:00 2001 From: Ryan2128 <33176053+Ryan2128@users.noreply.github.com> Date: Sat, 21 Nov 2020 11:04:52 +0800 Subject: [PATCH] fix(select): fix tag content error in multiple mode (#641) --- packages/select/src/useSelect.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/select/src/useSelect.ts b/packages/select/src/useSelect.ts index 7a7c4adfd3..258ae24942 100644 --- a/packages/select/src/useSelect.ts +++ b/packages/select/src/useSelect.ts @@ -21,6 +21,7 @@ import { } from '@element-plus/utils/util' import { elFormKey, elFormItemKey } from '@element-plus/form' import isEqual from 'lodash/isEqual' +import { toRawType } from '@vue/shared' import type { ElFormContext, ElFormItemContext } from '@element-plus/form' @@ -354,14 +355,14 @@ export const useSelect = (props, states: States, ctx) => { const getOption = value => { let option - const isObject = Object.prototype.toString.call(props.modelValue).toLowerCase() === '[object object]' - const isNull = Object.prototype.toString.call(props.modelValue).toLowerCase() === '[object null]' - const isUndefined = Object.prototype.toString.call(props.modelValue).toLowerCase() === '[object undefined]' + const isObject = toRawType(value).toLowerCase() === 'object' + const isNull = toRawType(value).toLowerCase() === 'null' + const isUndefined = toRawType(value).toLowerCase() === 'undefined' for (let i = states.cachedOptions.length - 1; i >= 0; i--) { const cachedOption = states.cachedOptions[i] const isEqual = isObject - ? getValueByPath(cachedOption.value, props.valueKey) === getValueByPath(props.modelValue, props.valueKey) + ? getValueByPath(cachedOption.value, props.valueKey) === getValueByPath(value, props.valueKey) : cachedOption.value === value if (isEqual) { option = {