摘要:
function getCacheData(key: string): any { return (window as any).cache[key]; } interface Cat { name: string; run(): void; } const tom = getCacheData(' 阅读全文
posted @ 2020-12-13 11:20
小翔momo
阅读(180)
评论(0)
推荐(0)
摘要:
function toBoolean(something: any): boolean { return something as boolean; } cc.log(toBoolean(1)); 上面代码输出还是1,something还是number类型,类型断言并没有什么用 function t 阅读全文
posted @ 2020-12-13 10:51
小翔momo
阅读(155)
评论(1)
推荐(0)
摘要:
interface Cat { run(): void; } interface Fish { swim(): void; } function testCat(cat: Cat) { return (cat as any as Fish); } 在上面的例子中,若直接使用 cat as Fish 阅读全文
posted @ 2020-12-13 10:34
小翔momo
阅读(200)
评论(0)
推荐(0)
浙公网安备 33010602011771号