Skip to content

Commit 1491fe4

Browse files
author
xuqingkai
committed
fix: 🐛 修复omitBy工具方法实现错误导致Tabbar等组件徽标显示异常的问题
1 parent 66bb94b commit 1491fe4

File tree

1 file changed

+3
-11
lines changed
  • src/uni_modules/wot-design-uni/components/common

1 file changed

+3
-11
lines changed

src/uni_modules/wot-design-uni/components/common/util.ts

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ export function isBoolean(value: any): value is boolean {
350350
return typeof value === 'boolean'
351351
}
352352

353-
export function isUndefined(value): value is undefined {
353+
export function isUndefined(value: any): value is undefined {
354354
return typeof value === 'undefined'
355355
}
356356

@@ -668,15 +668,7 @@ export const isH5 = process.env.UNI_PLATFORM === 'h5'
668668
* @returns
669669
*/
670670
export function omitBy<O extends Record<string, any>>(obj: O, predicate: (value: any, key: keyof O) => boolean): Partial<O> {
671-
const newObj = {}
672-
673-
const keys = Object.keys(obj)
674-
675-
for (const item in keys) {
676-
if (!predicate(obj[item], item)) {
677-
newObj[item] = obj[item]
678-
}
679-
}
680-
671+
const newObj = deepClone(obj)
672+
Object.keys(newObj).forEach((key) => predicate(newObj[key], key) && delete newObj[key]) // 遍历对象的键,删除值为不满足predicate的字段
681673
return newObj
682674
}

0 commit comments

Comments
 (0)