标签:date() port this div tst name string esc mat
1 export default { 26 getCookie(name) { 27 let reg = new RegExp(`(^| )${name}=([^;]*)(;|$)`) 28 let arr = document.cookie.match(reg) 29 return arr ? unescape(arr[2]) : null 30 }, 31 setCookie(c_name,value,expiredays){ 32 var exdate=new Date() 33 console.log(‘teken‘,value); 34 35 exdate.setDate(exdate.getDate()+expiredays) 36 document.cookie=c_name+ "=" +escape(value)+((expiredays==null) ? "" : ";expires="+exdate.toGMTString()) 37 }, 38 //删除cookies(配合setcookie进行操作,即设置为空) 39 delCookie(name) { 40 var exp = new Date(); 41 exp.setTime(exp.getTime() - 1); 42 var cval=this.getCookie(name); 43 if(cval!=null) document.cookie= name + "="+cval+";expires="+exp.toGMTString(); 44 } 45 }
标签:date() port this div tst name string esc mat
原文地址:https://www.cnblogs.com/wendyAndJken/p/9321604.html