赞
踩
- /**
- * 设置是否登录且未关闭浏览器cookie
- */
- export const setCookiesIsCloseBrowser = () => {
- document.cookie = 'islogin=true'
- }
-
- /**
- * 获取指定cookie
- * @param {cookie} cookieName
- * @returns cookie值
- */
- export const getCookie = (cookieName) => {
- const strCookie = document.cookie
- const cookieList = strCookie.split(';')
-
- for (let i = 0; i < cookieList.length; i++) {
- const arr = cookieList[i].split('=')
- if (cookieName === arr[0]) {
- return arr[1]
- }
- }
-
- return ''
- }
-
- /**
- * 删除指定cookie
- * @param {*cookie} cookieName
- */
- export const deleteCookie = (cookieName) => {
- var exp = new Date();
- exp.setTime(exp.getTime() - 1);
- var cval = getCookie(cookieName);
- if (cval != null) document.cookie = cookieName + "=" + cval + ";expires=" + exp.toGMTString();
- }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。