您的位置: 首页 > IT文章 > 类型断言 类型断言 分类: IT文章 • 2025-02-06 15:27:01 let someValue: any = 'this is a string' // 类型断言方式一: let strLength: number = (<string>someValue).length // 类型断言方式二:【推荐使用这种方式】 let strLength: number = (someValue as string).length