使用ts(typeScript)引入element 等ui框架 出现this需要声明的问题

配置tsconfig.json 

  // 编译选项
  "compilerOptions": {
    "noImplicitThis": false, // 忽略 this 的类型检查, Raise error on this expressions with an implied any type.
  }
配置完之后 就可以直接this.xxx 使用全局引入的element框架了  在使用vue的$refs的时候也不用像下面这样声明了
    refFun(formName: string): HTMLFormElement {
      const ref: HTMLFormElement = this.$refs[formName] as HTMLFormElement
      return ref
    },

 

posted @ 2021-05-18 18:34  Model-Zachary  阅读(357)  评论(0编辑  收藏  举报