我在 Angular 12 版中使用 Zxing Scanner 组件。我在很多地方都遇到了这个错误。
/**
* Returns a valid BarcodeFormat or fails.
*/
private getBarcodeFormat(format: string | BarcodeFormat): BarcodeFormat {
return typeof format === 'string'
? BarcodeFormat[format.trim().toUpperCase()]
: format;
}
错误在这一行[format.trim().toUpperCase()]
,当我悬停时它会显示Element implicitly has an 'any' type because index expression is not of type 'number'.ts(7015)
。
为什么会出现这个错误??我该如何解决?
我需要一个完美的解决方案,而无需更改angular.json或package.json中的任何配置