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