vue中使用cookie实现记住用户上一次的选择-创新互联
vue中使用cookie实现记住用户上一次的选择?很多新手对此不是很清楚,为了帮助大家解决这个难题,下面小编将为大家详细讲解,有这方面需求的人可以来学习下,希望你能有所收获。

//设置cookie
setCookie(projectId,exdays) {
var exdate=new Date();//获取时间
exdate.setTime(exdate.getTime() + 24*60*60*1000*exdays);//保存的天数
//字符串拼接cookie
window.document.cookie="projectId"+ "=" +projectId+";expires="+exdate.toGMTString();
},
//读取cookie
getCookie:function () {
console.log(document.cookie);
let me=this;
if (document.cookie.length>0) {
var arr=document.cookie.split('; ');//这里显示的格式需要切割一下自己可输出看下
for(var i=0;i
当前题目:vue中使用cookie实现记住用户上一次的选择-创新互联
本文地址:http://www.jxjierui.cn/article/dghocj.html


咨询
建站咨询
