问答详情
源自:3-1 高阶组件实现

装饰器@使用

//.babelrc
{"presets":["react-native-stage-0/decorator-support"]}
ps:如果上面出现报错
Cannot find module 'react-native-stage-0/decorator-suppor
npm install metro-react-native-babel-preset -D
将.babelrc改为
{
  "presets": ["module:metro-react-native-babel-preset"],
   "plugins": [
    ["@babel/plugin-proposal-decorators", { "legacy": true }]   
  ]
}



提问者:azmake 2019-11-28 16:49

个回答

  • azmake
    2019-11-28 16:50:26

    //.babelrc
    {"presets":["react-native-stage-0/decorator-support"]}
    ps:如果上面出现报错
    Cannot find module 'react-native-stage-0/decorator-suppor
    npm install metro-react-native-babel-preset -D
    将.babelrc改为
    {
      "presets": ["module:metro-react-native-babel-preset"],
       "plugins": [
        ["@babel/plugin-proposal-decorators", { "legacy": true }]   
      ]
    }