JavaScript/typescript/类型:修订间差异
来自康健生活
< JavaScript | typescript
| (未显示同一用户的1个中间版本) | |||
| 第17行: | 第17行: | ||
}) | }) | ||
</syntaxhighlight> | </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