如何清除react-native-webview和
的 localStorage清除网络视图的本地存储的最佳方法是什么
答案 0 :(得分:0)
我们可以使用clearLocalStorage = () => {
this.setState({ isCookieClear: true }, () => {
setTimeout(() => {
this.setState({ isCookieClear: false });
}, 2000);
});
};
清除本地存储。我们可以称之为this.clearLocalStorage();清除localStorage
const {isCookieClear}=this.state;
let myInjectedJs = `(function(){
${isCookieClear?`window.localStorage.clear(); `:''}
})();`
return (
<WebView
ref="webview"
javaScriptEnabled={true}
domStorageEnabled={true}
injectedJavaScript={myInjectedJs}
useWebKit={true}
/>
)
<div class='col-12 col-xl-6'>