TypeScript学习(十三)常见问题

1、在ts中使用正则表达式

引用类型之正则表达式

2、ts报错元素隐式具有“any” 类型,因为索引表达式的类型不为‘number‘

在开发vip需求我的礼包时遇到一个ts报错元素隐式具有“any” 类型,因为索引表达式的类型不为‘number‘

解决

1. 错误写法为:

window["CESIUM_BASE_URL"]="src/assets/cesium"

2. 正确写法为:

(window as any).CESIUM_BASE_URL = 'src/assets/cesium/';

 

原文地址:https://www.cnblogs.com/kunmomo/p/15745592.html