React Native WebView关闭缓存


React Native WebView关闭缓存

网上搜索没有找到关闭React Native下webview控件的缓存的方法,经测试找到解决方案,记录如下

  • 核心思路:通过请求时设置请求头,使页面缓存过期

关键代码

<View style={styles.container}> <WebView source={{ uri: "http://somehost/somepath/file.html", method: 'GET', headers: { 'Cache-Control':'no-cache'} }} style={{ width: Dimensions.get('window').width, height: Dimensions.get('window').height }}></WebView> </View>
  • 核心代码: 在source里面指定headers中的Cache-Control为no-cache


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM