babel编译decorator

@babel7.x

npm install --save-dev @babel/plugin-proposal-decorators
package.json 里的babel配置,添加:

{
      "plugins": [
            ["@babel/plugin-proposal-decorators", { "legacy": true }],
            ["@babel/plugin-proposal-class-properties", { "loose" : true }]
      ]
}

只能如下使用:export @decorator class Bar {}
不能:@decorator
export class Foo {}
解决办法还在搜寻中

猜你喜欢

转载自www.cnblogs.com/tdd-qdkfgcs/p/11275634.html