export default {
getCookie(name) {
let reg = new RegExp(`(^| )${name}=([^;]*)(;|$)`)
let arr = document.cookie.match(reg)
return arr ? unescape(arr[2]) : null
},
setCookie(c_name,value,expiredays){
var exdate=new Date()
console.log(‘teken‘,value);
exdate.setDate(exdate.getDate()+expiredays)
document.cookie=c_name+ "=" +escape(value)+((expiredays==null) ? "" : ";expires="+exdate.toGMTString())
},
//删除cookies(配合setcookie进行操作,即设置为空)
delCookie(name) {
var exp = new Date();
exp.setTime(exp.getTime() - 1);
var cval=this.getCookie(name);
if(cval!=null) document.cookie= name + "="+cval+";expires="+exp.toGMTString();
}
}
03-07
1111
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)