以React,Nextjs開頭的打字稿
我有以下類,它在訪問avatar和name
Property does not exists on type readonly

我怎樣才能正確地對屬性進行型別轉換?
uj5u.com熱心網友回復:
React.Component是一個泛型類。您可以在那里指定道具:
interface AvatarProps {
avatar?: string;
name: string;
}
class Avatar extends React.Component<AvatarProps> {
如果你忽略它,默認是假設沒有道具。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/419753.html
標籤:
