fix(utils): avoid getting unexpected value (#11010)

For example, when calling `get({}, 'button.small')`, it expects to return an empty string, but return a function (`''.small` is a native function, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/small).
This commit is contained in:
Fengyuan Chen 2022-09-05 23:30:46 +08:00 committed by chenjiahan
parent bc024a105c
commit cd439c04f3

View File

@ -1,3 +1,4 @@
import { isObject } from './validate';
import type { ComponentPublicInstance } from 'vue';
export function noop() {}
@ -16,7 +17,7 @@ export function get(object: any, path: string): any {
let result = object;
keys.forEach((key) => {
result = result[key] ?? '';
result = isObject(result) ? result[key] ?? '' : '';
});
return result;