// 获取cookieexportfunctiongetCookie(Name){var findcookie = Name +'=';if(window.document.cookie.length >0){// if there are any cookieslet offset = window.document.cookie.indexOf(findcookie);if(offset !=-1){// if cookie exists
offset += findcookie.length;// set index of beginning of valuelet end = window.document.cookie.indexOf(';', offset);// set index of end of cookie valueif(end ==-1) end = window.document.cookie.length;returnunescape(window.document.cookie.substring(offset, end));}}returnnull;}// 设置cookieexportfunctioncookieGO(value, key){var today =newDate();var expires =newDate();
expires.setTime(today.getTime()+1000*60*60*24);setCookie(value, key, expires);}exportfunctionsetCookie(value, key, expire){
window.document.cookie =
value +'='+escape(key)+(expire ==null?'':'; expires='+ expire.toGMTString());}
·使用此方法判断一个弹窗24小时只展示一次
判断cookie中有无此字段,有的话就直接取或者判断来使用,无就种上
handleShowStayDialog=()=>{var c =getCookie(cookieStr);// cookieStr为要查询的字段if(c ===null){// 如果为空,不为空证明24小时还没过,不展示 this.showDialog();// 展示弹窗setTimeout(cookieGO('cookieStr','already'),2000);// 种上cookiereturnfalse;}};