android - 在 iOS 和 Android 中使用本机反应的 webview 组件的性能问题
问题描述
当我运行 React Native 的 WebView 组件时,我遇到了性能问题,只需从该组件加载页面大约需要 11 秒,而从本机代码加载页面需要 2 秒。请有人帮助我,组件的配置可能没有正确分配它。
这是调用组件的代码的一部分:
<Webview
ref={webviewRef}
style={{ backgroundColor: colors.WHITE }}
sharedCookiesEnabled={true}
startInLoadingState={true}
bounces={false}
renderLoading={loadingIndicator}
showsHorizontalScrollIndicator={false}
showsVerticalScrollIndicator={false}
onError={console.error.bind(console, "error")}
injectedJavaScriptBeforeContentLoaded={didomiJs}
injectedJavaScript={webviewUtils.injectGetWeviewScrollTop()}
javaScriptEnabled={true}
domStorageEnabled={true}
setSupportMultipleWindows={false}
originWhitelist={configuration.PROTOCOLS.PROTOCOL_ACCEPTED_IN_WEBVIEWS}
onMessage={(event) => {
onMessage({ event });
}}
source={{
uri: currentUrl
}}
onNavigationStateChange={(navState) => {
setCanGoBack(navState.canGoBack);
}}
onShouldStartLoadWithRequest={(request) => {
return requestOnStart({ request });
}}
/>
解决方案
推荐阅读
- python - 使用 Beautifulsoup 传递表数据
- java - 在发布新帖子之前为用户提供类似帖子的功能的逻辑是什么?
- flutter - 创建 StatefulWidget 时访问 Flutter 上下文
- graphql - 如何在“react-apollo”应用程序中定义客户端模式?
- mysql - 如何跨表获取时间序列数据的值总和
- php - PHP-FFMpeg 视频输出被截断
- html - 背景颜色整页
- html - iOS Safari html5 视频自动播放比 6 个月前需要更长的时间?
- c++ - 我无法捕获和处理浮点异常?
- c++ - 你能声明一个成员函数并让它们做不同的事情吗?