fix: 添加ts类型

This commit is contained in:
shaohuzhang1 2024-03-29 18:47:34 +08:00
parent c55bb3f6e5
commit d0e4218323
2 changed files with 3 additions and 3 deletions

View File

@ -4,7 +4,7 @@ import moment from 'moment'
export const nowDate = moment().format('YYYY-MM-DD')
// 当前时间的前n天
export function beforeDay(n) {
export function beforeDay(n: number | string) {
return moment().subtract(n, 'days').format('YYYY-MM-DD')
}

View File

@ -66,13 +66,13 @@ export function isAllPropertiesEmpty(obj: object) {
}
// 数组对象中某一属性值的集合
export function getAttrsArray(array, attr) {
export function getAttrsArray(array: Array<any>, attr: string) {
return array.map((item) => {
return item[attr]
})
}
// 求和
export function getSum(array) {
export function getSum(array: Array<any>) {
return array.reduce((totol, item) => totol + item, 0)
}