gpt4 book ai didi

react-native - 为什么多个WebView不能共享缓存?

转载 作者:行者123 更新时间:2023-12-05 07:03:32 32 4
gpt4 key购买 nike

我有一个用 react-native 开发的应用程序。使用了 react-native-webview 和 react-navigation 插件。

当我打开一个包含webview的界面,然后跳转到另一个包含webview的界面时,发现他们无法共享缓存。上一页引用的静态文件在下一页再次加载。

但是如果我在同一个 webview 中重定向网页的 url,缓存工作并且一切正常。

react-native-webview使用默认配置,静态文件请求的cache-control正常

不知道android下的webview性能是这样的,还是其他问题?

enter image description here

 <WebView
ref={this.webview}
source={{uri: url}}
mixedContentMode="compatibility"
useWebKit={true}
allowsInlineMediaPlayback={true}
allowsFullscreenVideo={true}
onNavigationStateChange={this._onNavigationStateChange}
onLoadStart={this._onLoadStart}
onLoadEnd={this._onLoadEnd}
onMessage={this.invoke.listener}
/>

最佳答案

设置sharedCookiesEnabled={true}

关于react-native - 为什么多个WebView不能共享缓存?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63172218/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com