javascript - 根据界面格式化上层密钥的最佳方法
问题描述
实现以下目标的最佳方法是什么:
export interface Iabc {
startDate: Date | string | null;
endDate: Date | string | null;
nestedSection: {
a: string | null;
b: boolean | null;
c: boolean | null;
d: Date | string | null;
};
}
目前我正在转换嵌套部分中包含的日期,如下所示
nestedSection: Object.entries(values.nestedSection).reduce((prev, [k, v]) => {
if (v instanceof Date) {
return {
...prev,
[k]: moment(v).format('YYYY-MM-DD'),
};
}
return prev;
}, values.nestedSection),
但是,我需要为嵌套部分的 startDate 和 endDate 执行此操作。TIA
解决方案
推荐阅读
- ios - 扫描成功后如何关闭二维码扫描器 - Swift 4
- php - 使用 PHP 变量名创建表不起作用
- mysql - 使用 SQOOP 将数据从 MYSQL 导入 HIVE
- php - PHP Prepared Statements,如何将数据从一列转移到另一列
- karate - 如何动态设置从空手道文件读取的json中的值
- java - 没有 X11 转发时远程运行 emacs 失败
- awk - 用awk替换xml标签之间的多行文本
- kotlin - 我应该如何为属性定义这些复杂的初始化程序
- maven - 即使设置代理,Maven也无法下载依赖项
- postgresql - 在 INSERT INTO 之后返回带有 where 条件的行数?PostgreSQL