【问题标题】:React Native Expo build:web blank pageReact Native Expo build:web 空白页
【发布时间】:2020-10-11 16:44:30
【问题描述】:

我有一个为 iOS、Android 构建的现有 React Native 项目,我可以使用 expo start 命令在 web 中运行,但我无法运行 expo build:web 并在本地运行它

npx serve web-build

空白页中的控制台显示:

ReferenceError: Platform is not defined

在我的代码中,我有以下内容:

<KeyboardAvoidingView
behavior={Platform.OS == "ios" ? "padding" : "height"}
style={styles.container}
>

如果我尝试通过 Git 连接将相同的代码部署到 Amplify,它会返回一个错误,例如

No such file ./components/myComponent.js

我不确定为什么它不能在任何一个 Web 部署上运行

任何帮助将不胜感激

【问题讨论】:

    标签: reactjs react-native expo


    【解决方案1】:

    您需要导入平台:

    import { Platform } from 'react-native';
    

    【讨论】:

      猜你喜欢
      • 2021-09-05
      • 1970-01-01
      • 2018-09-18
      • 1970-01-01
      • 1970-01-01
      • 2023-03-27
      • 1970-01-01
      • 2023-02-05
      • 1970-01-01
      相关资源
      最近更新 更多