as关键字表示断言
在Typescript中,表示断言有两种方法。一种是括号表示法:
let someValue: any = "this is a string";
let strLength: number = (someValue).length;
另一种使用as关键字:
let someValue: any = "this is a string";
let strLength: number = (someValue as string).length;
在Typescript中,表示断言有两种方法。一种是括号表示法:
let someValue: any = "this is a string";
let strLength: number = (someValue).length;
另一种使用as关键字:
let someValue: any = "this is a string";
let strLength: number = (someValue as string).length;