ts 参数默认类型设置
常用的参数类型设置
title: string; data: any[]; type: string; QC: number; activeKey: string[]; changeCollapse: any;
例子:默认穿一个字符串数组的参数类型
export const getSettingKeys = async (UserSettingKeys:string[]) => { if(UserSettingKeys.length<1) return const keys = UserSettingKeys; const res = await store.systemSettingManager.getConfigsByKeys({ keys, objectId: store.currentUser.id, nestObject: true, }); return res };
有确定类型的默认值赋值
const fun = (num1: number = 1, num2?:number): number => { return num1 + (num2?num2:0) }