下午自己學(xué)習(xí)了下mobx ,然后接觸到了decorator裝飾器,接著用visual studio code 寫mobx 和 react的代碼;寫到如下的代碼時(shí):
image.png
Experimental support for decorators is a feature that is subject to change in a future release. Set the ‘experimentalDecorators’ option to remove this warning.
編輯器竟然在observer哪里報(bào)了個(gè)紅線的warning,于是我找到了如下的方法解決:
在項(xiàng)目目錄下新建tsconfig.json文件,然后加入如下配置就可以完美解決了。
{
"compilerOptions": {
"experimentalDecorators": true,
"allowJs": true
}
}
重新打開vsc編輯器就不會(huì)顯示那條紅線了。
image.png