【发布时间】:2020-03-25 17:54:10
【问题描述】:
我有一个带有注入 Javascript 的 HTML 代码,它执行并启动验证服务。它在开发模式下工作得很好,但在生产模式下却不行。
<WebView
allowFileAccess={true}
source={(getSource(file))}
javaScriptEnabled={true}
injectedJavaScript={script}
originWhitelist={["https://*", "http://*", "file://*", "asset://*"]}
/>
const download = async () => {
let file = Asset.fromModule(html);
if (file.localUri !== null) {
return file
}
await file.downloadAsync() // Optional, saves file into cache
console.log('file', file)
return file
}
const getSource = (file) => {
if (Platform.OS !== 'android') {
return html
}
if (file === null) {
return {}
}
return {
uri: file.localUri
}
}
【问题讨论】:
-
你能分享一个完整的可运行示例吗?生产模式是指在独立应用程序中还是在禁用开发模式的 expo 客户端中?
-
@brentvatne 我有一个 Expo 应用程序。我在生产模式和开发模式下都进行了检查,还安装了 .apk 文件。你需要从代码中得到什么,所以我可以和你分享?
标签: javascript html react-native webview expo