首页 > 解决方案 > -canOpenURL:URL 失败:“file:///var/containers/Bundle/Application/{path}” - 错误:“操作

问题描述

我正在将一个 HTML 文件加载到我的应用程序中并向用户显示一些信息。HTML 文件是我的应用程序捆绑资源的一部分。我在控制台中注意到以下错误:

-canOpenURL: failed for URL: "file:///var/containers/Bundle/Application/{somePath}/" - error: "This app is not allowed to query for scheme file"

那么,我在 info.plist 中添加了以下键:

<key>LSApplicationQueriesSchemes</key>
<array>
  <string>file</string>
</array> 

我得到一个不同的错误:

-canOpenURL: failed for URL: "file:///var/containers/Bundle/Application/{somePath}/" - error: "The operation couldn’t be completed. (OSStatus error -10814.)"

即使我收到此错误,我也可以毫无问题地打开 HTML 文件。

你们有任何提示如何解决这个错误吗?

标签: iosswiftios11

解决方案


 <WebView
        originWhitelist={['*']}
        source={{ html: '<h1>Hello world</h1>' }}
      />

originWhitelist={['*']}解决了我的问题


推荐阅读