mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-05-20 05:29:14 +08:00
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:
parent
bc024a105c
commit
cd439c04f3
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user