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
416 0
|
9月前
UnboundLocalError: local variable ‘loss’ referenced before assignment解决方法
UnboundLocalError: local variable ‘loss’ referenced before assignment解决方法
156 0
syntax error, expect {, actual [, pos 0 at
syntax error, expect {, actual [, pos 0 at
131 0
解决办法:configure: error: You requested SRTP (requires libsrtp) but not found...die
解决办法:configure: error: You requested SRTP (requires libsrtp) but not found...die
117 0
configure: error: You requested LIBYUV but not found...die
configure: error: You requested LIBYUV but not found...die
67 0
configure: error: readline library not found/libreadline.so: undefined reference to tputs
configure: error: readline library not found/libreadline.so: undefined reference to tputs
325 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这句去掉就好了。
5115 0