不知道为什么有的IE11浏览器不支持localStorage,在此记录一下
- ie11 使用localstorage,不支持,不得不做一些判断,比如
if(window.localStorage && typeof window.localStorage.clear === 'function'){
window.localStorage.clear();
}
if(window.localStorage&&window.localStorage['MY_ANYCHAT_STORE_STATE']){
state = JSON.parse(window.localStorage['MY_ANYCHAT_STORE_STATE']);
}
if(window.localStorage && typeof window.localStorage.setItem === 'function'){
window.localStorage.setItem('MY_ANYCHAT_STORE_STATE',JSON.stringify(store.getState()));
}
网友评论