【问题标题】:React Native Android cannot load html file from localReact Native Android 无法从本地加载 html 文件
【发布时间】:2020-06-19 04:54:01
【问题描述】:

我想在我的 React Native App 中加载一个本地 html 文件。它在 IOS 中有效,但在 Android 中失败。这是我的代码:-

 <WebView
          originWhitelist={['*']}
          source={Platform.OS === 'android' ? { uri: 'file:///android_asset/index.html' } : require('../screens/index.html')}
          startInLoadingState={true}
          />

这是我的本地 html 文件路径。

我不知道我应该在哪里配置才能让它工作......请帮助。谢谢。

【问题讨论】:

    标签: android react-native webview local-files


    【解决方案1】:

    代码正在运行。每次更改 android 文件夹时记得重启你的反应服务器

    【讨论】:

    • 嗨@Harpreet,我使用 expo 编译应用程序...我该怎么办?
    • @Eddy 对 expo 没有太多经验,你可以参考这个:forums.expo.io/t/… 我认为没有必要在 expo 的 android 文件夹中添加 html 文件,我可能错了。让我知道结果
    猜你喜欢
    • 2020-07-19
    • 2020-04-08
    • 1970-01-01
    • 1970-01-01
    • 2017-12-27
    • 1970-01-01
    • 2019-11-18
    • 2017-09-15
    • 2020-01-03
    相关资源
    最近更新 更多