原文:react中使用typescript時,error: Property 'setState' does not exist on type 'Home'

問題描述: 我在react中用typescript時,定義一個Home組件,然后在組件里用setState時會有這樣一個報錯: 如圖 Property setState does not exist on type Home 分析解決: 報錯說我的Home組件上不存在setState屬性,但是我把文件的后綴名從 .tsx 改成 .jsx 就不報這個錯了,推斷是typescript的類型檢查報的這個 ...

2019-12-06 18:50 0 514 推薦指數:

查看詳情

TypeScript 錯誤property does not exist on type Object

TypeScript 錯誤property does not exist on type Object 在TypeScript中如果按JS的方式去獲取對象屬性,有時會提示形如Property 'value' does not exist on type 'Object'的錯誤。具體代碼 ...

Fri Nov 30 22:03:00 CST 2018 4 8926
TypeScript知識:Property 'xxx' does not exist on type 'never'.

一、報錯提示:Property 'xxx' does not exist on type 'never'.   開發過程中出現這個錯誤是因為Typescript在執行代碼檢查在該對象沒有定義相應屬性,這個錯誤不致命,遇到該錯誤有以下幾種解決辦法。 1、將對象設置成 any ...

Sat May 22 07:16:00 CST 2021 0 16348
 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM