JavaScript/typescript/类型:修订间差异
来自康健生活
< JavaScript | typescript
| (未显示同一用户的2个中间版本) | |||
| 第8行: | 第8行: | ||
const obj: Record<string | number | symbol, any> = {};</syntaxhighlight> | const obj: Record<string | number | symbol, any> = {};</syntaxhighlight> | ||
===== Promise<void> ===== | ===== Promise<void> ===== | ||
Promise 返回值设定 | |||
<syntaxhighlight lang="javascript"> | |||
new Promise<number> | |||
// or | |||
new Promise((reslove: (value:number)=>void, reject)=>{ | |||
// reslove | |||
}) | |||
</syntaxhighlight> | |||
== ...params: any[] == | |||
可变参数 | |||
<syntaxhighlight lang="typescript"> | |||
interface HttpFetchInterface { | |||
fetch(...params: any[]): Promise<object>; | |||
} | |||
async fetch (username:string, password:string, httpMethod?:string): Promise<object>{</syntaxhighlight> | |||
2020年8月28日 (五) 03:31的最新版本
标题文字
Record<string, unknown>
定义一个任意类型的对象
{[propname:any]:any}
// or
const obj: Record<string | number | symbol, any> = {};
Promise<void>
Promise 返回值设定
new Promise<number>
// or
new Promise((reslove: (value:number)=>void, reject)=>{
// reslove
})
...params: any[]
可变参数
interface HttpFetchInterface {
fetch(...params: any[]): Promise<object>;
}
async fetch (username:string, password:string, httpMethod?:string): Promise<object>{
No categories