設置緩存數據:localStorage.setItem('OLDPROJID', oldprojid);html
獲取換成數據:let dataUser = localStorage.getItem('user_claims');前端
清除緩存數據: localStorage.removeItem('OLDPROJID', oldprojid);vue
獲取緩存數據:let expendKeys = window.localStorage.getItem('expendKeys');react
設置緩存數據:window.localStorage.setItem('expendKeys', JSON.stringify(this.defaultExpandRowKeys));瀏覽器
清除緩存數據:window.localStorage.removeItem('expendKeys');緩存
一、手工設置cookie
到瀏覽器控制檯找到Application->Cookies->路徑,name -> (設置cookie名,好比設爲login), value ->(設置cookie值,好比設爲true)this
二、js設置cookiecode
<script> export default { methods: { handleClick () { const expires = 900 * 24 * 60 * 60 * 1000; const date = new Date(+new Date() + expires); document.cookie = `login=true;expires=${date.toUTCString(expires)}` } } } </script>
三、獲取cookiehtm
const isLogin = document.cookie.includes('login=true');//校驗cookie