typescript常見問題集錦


1.在ts中,碰到Element implicitly has an 'any' type because expression of type 'string' can't be used to index type 'Object'.   No index signature with a parameter of type 'string' was found on type 'Object'.

這種問題測出現時說:元素隱式具有“any”類型,因為“string”類型的表達式不能用於索引類型“Object”。在類型“Object”上找不到“string”類型參數的索引簽名。

要想解決這類問題,需要在tsconfig.json文件中配置:"suppressImplicitAnyIndexErrors": true 就可以解決此類問題。

2.在vue中,使用此命令 vue add @vue/typescript,出現如下錯誤得時候:

 

 在對應得文件夾中刪除vue.ps1就ok了。

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM