2

我正在使用 react native web 设置 web 应用程序。我想为 UI 组件使用本机基础,但无法在 Web 中使用它。我已遵循此说明https://github.com/GeekyAnts/NativeBase-KitchenSink/tree/web-support

由于这个关于图书馆的官方信息。

我使用以下命令创建 web 应用程序 yarn create react-app test-web --typescript

然后添加 yarn add react-native@0.55.4 react-native-web@0.10.0 react -art@16.8.2 yarn add -D @types/react-native@0.55.4

我的项目中没有 babel 配置,那么我该如何解决这个问题 在此处输入图像描述

我的 package.json 文件

{
  "name": "test-web",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@babel/plugin-proposal-class-properties": "^7.3.4",
    "customize-cra": "^0.2.12",
    "native-base": "^2.12.1",
    "react": "^16.8.4",
    "react-app-rewired": "^2.1.1",
    "react-art": "16.8.2",
    "react-dom": "^16.8.4",
    "react-native": "0.55.4",
    "react-native-web": "0.10.0",
    "react-navigation": "^3.3.2",
    "react-scripts": "2.1.8"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": "react-app"
  },
  "browserslist": [
    ">0.2%",
    "not dead",
    "not ie <= 11",
    "not op_mini all"
  ],
  "devDependencies": {
    "@types/react-native": "0.55.4"
  }
}

4

1 回答 1

0

您是否将插件添加到您的移动或应用目录中的 babel.config.js 文件中?

module.exports = {
     presets: ['module:metro-react-native-babel-preset'],
     plugins: ['@babel/plugin-proposal-class-properties']
};
于 2019-07-27T21:37:48.127 回答