eslint報(bào)錯(cuò)
1,類(lèi)型“Window”上不存在屬性“wx”鼻吮。ts(2339)
image.png
解決:根目錄新建文件:類(lèi)型定義文件(.d.ts*)
.d.ts
.d.ts
interface Window {
wx: string;
}
2,類(lèi)型“Readonly<{}>”上不存在屬性“merId”像街。
image.png
- 只要在組件內(nèi)部使用了props和state当辐,就需要在聲明組件時(shí)指明其類(lèi)型抖僵。
解決:
(一)
class MerList extends PureComponent<{dispatch,spending},{merId:string,merName:string}>{
}
改成
(二)
export interface MerlistState {
merId: string;
merName: string;
}
@connect(({ spending }) => ({
spending,
// loading,
}))
class MerList extends PureComponent<MerlistProps,MerlistState>{
constructor(props) {
super(props);
this.state = {
merId:'',
merName:''
};
}
}