1

我希望能够在代码沙箱中的@observer打字稿代码中使用 mobx。但是我收到此错误:

/src/content.tsx:目前未启用对实验性语法“decorators-legacy”的支持 (6:1):

  4 | import { observer } from "mobx-react";
  5 | 
> 6 | @observer
    | ^
  7 | export class Particle extends React.Component {

我已经:

1) 添加依赖项

在此处输入图像描述

2)添加.babelrc包含这些内容的文件

在此处输入图像描述

但我无法摆脱错误。我该如何解决?

4

2 回答 2

0

File > Preference > Settings > Search "experimental"

然后检查Javascript › Implicit Project Config: Experimental Decorators

于 2021-07-27T01:46:09.043 回答
0

将此添加到 tsconfig.json:

"compilerOptions": {
 "experimentalDecorators": true
于 2019-07-29T18:21:11.367 回答