Unexpected aliasing of ‘this‘ to local variable.

简介: Unexpected aliasing of ‘this‘ to local variable.

报错原因:怕全局“this”与局部变量发生混叠。
在这里插入图片描述
解决:按照eslint官方给出的解决方式在.eslintrc.js文件中备注this可用的局部变量名称
在这里插入图片描述

{
  "@typescript-eslint/no-this-alias": [
    "error",
    {
      "allowDestructuring": false, // Disallow `const { props, state } = this`; true by default
      "allowedNames": ["self"] // Allow `const self = this`; `[]` by default
    }
  ]
}

修改完成后要修改对应文件内局部this变量名称即可
在这里插入图片描述

目录
相关文章
undefined reference to symbol 'dlsym@@GLIBC_2.17' libdl.so: error adding symbols: DSO missing from c
undefined reference to symbol 'dlsym@@GLIBC_2.17' libdl.so: error adding symbols: DSO missing from c
589 0
|
7月前
|
Unix Linux Shell
syntax error: unexpected end of file
syntax error: unexpected end of file
33 0
error C2449: found ‘{‘ at file scope (missing function header?)和error C2059: syntax error : ‘}‘
error C2449: found ‘{‘ at file scope (missing function header?)和error C2059: syntax error : ‘}‘
124 0
UnboundLocalError: local variable ‘loss’ referenced before assignment解决方法
UnboundLocalError: local variable ‘loss’ referenced before assignment解决方法
232 0
|
关系型数据库 MySQL C++
Error:error C2601: ‘b‘ : local function definitions are illegal error C2063: ‘b‘ : not a function
Error:error C2601: ‘b‘ : local function definitions are illegal error C2063: ‘b‘ : not a function
181 0
|
并行计算 PyTorch 算法框架/工具
CUDA unknown error - this may be due to an incorrectly set up environment 问题解决
CUDA unknown error - this may be due to an incorrectly set up environment 问题解决
CUDA unknown error - this may be due to an incorrectly set up environment 问题解决
|
PHP
【PHP报错集锦】 Maximum function nesting level of ‘256‘ reached, aborting!
【PHP报错集锦】 Maximum function nesting level of ‘256‘ reached, aborting!
451 0
【PHP报错集锦】 Maximum function nesting level of ‘256‘ reached, aborting!
configure: error: readline library not found/libreadline.so: undefined reference to tputs
configure: error: readline library not found/libreadline.so: undefined reference to tputs
386 0
|
Python
local variable 'xxx' referenced before assignment
定义了一个全局变量 s ,Python的一个函数里面引用这个变量,并改变它的值, 结果报错local variable 'xxx' referenced before assignment, 代码如下: s = 2   def fun():        if s== 2:           print s         s= 3           错误的意思就是s这个变量在引用前还没有定义,这上面不是定义了么?但是后来我把s= 2这句去掉就好了。
5189 0