美文网首页工作生活
类型“Window”上不存在属性“wx”。ts(2339

类型“Window”上不存在属性“wx”。ts(2339

作者: JennyGao66 | 来源:发表于2019-07-05 15:30 被阅读0次

    eslint报错

    1,类型“Window”上不存在属性“wx”。ts(2339)

    image.png
    解决:根目录新建文件:类型定义文件(.d.ts*) .d.ts
    .d.ts
    interface Window {
      wx: string;
    }
    

    2,类型“Readonly<{}>”上不存在属性“merId”。


    image.png
    • 只要在组件内部使用了props和state,就需要在声明组件时指明其类型。
      解决:
      (一)
    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:''
        };
      }
    }
    

    相关文章

      网友评论

        本文标题:类型“Window”上不存在属性“wx”。ts(2339

        本文链接:https://www.haomeiwen.com/subject/ycuzcctx.html