微信小程序页面迁移校验之前 P5任务处理之前
This commit is contained in:
21
apps/miniprogram - 副本/miniprogram/utils/render.ts
Normal file
21
apps/miniprogram - 副本/miniprogram/utils/render.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
/**
|
||||
* 渲染辅助工具函数
|
||||
* 纯函数,无 wx.* 依赖
|
||||
*/
|
||||
|
||||
/**
|
||||
* 从对象中提取指定字段,缺失字段填充 null
|
||||
* @param item 数据对象
|
||||
* @param fieldList 需要的字段名数组
|
||||
* @returns 仅包含指定字段的新对象
|
||||
*/
|
||||
export function getRequiredFields(
|
||||
item: Record<string, any>,
|
||||
fieldList: string[]
|
||||
): Record<string, any> {
|
||||
const result: Record<string, any> = {}
|
||||
for (const field of fieldList) {
|
||||
result[field] = field in item ? item[field] : null
|
||||
}
|
||||
return result
|
||||
}
|
||||
Reference in New Issue
Block a user