如何清除 react-native-webview 的本地存储?
how to clear local storage of react-native-webview?
如何清除 react-native-webview 和
的 localStorage
清除 webview
的 localstorage 的最佳方法是什么
我们可以使用injectedJavaScript
清除本地存储。我们可以调用 this.clearLocalStorage();清除 localStorage
clearLocalStorage = () => {
this.setState({ isCookieClear: true }, () => {
setTimeout(() => {
this.setState({ isCookieClear: false });
}, 2000);
});
};
const {isCookieClear}=this.state;
let myInjectedJs = `(function(){
${isCookieClear?`window.localStorage.clear(); `:''}
})();`
return (
<WebView
ref="webview"
javaScriptEnabled={true}
domStorageEnabled={true}
injectedJavaScript={myInjectedJs}
useWebKit={true}
/>
)
如何清除 react-native-webview 和
的 localStorage清除 webview
的 localstorage 的最佳方法是什么我们可以使用injectedJavaScript
清除本地存储。我们可以调用 this.clearLocalStorage();清除 localStorage
clearLocalStorage = () => {
this.setState({ isCookieClear: true }, () => {
setTimeout(() => {
this.setState({ isCookieClear: false });
}, 2000);
});
};
const {isCookieClear}=this.state;
let myInjectedJs = `(function(){
${isCookieClear?`window.localStorage.clear(); `:''}
})();`
return (
<WebView
ref="webview"
javaScriptEnabled={true}
domStorageEnabled={true}
injectedJavaScript={myInjectedJs}
useWebKit={true}
/>
)