标签:ken border translate cookie abs word port length href
1.cooks:
1 setCookie:function(name,value,expires){ 2 3 var LargeExpDate = new Date(); 4 LargeExpDate.setTime(LargeExpDate.getTime() + (expires*1000*3600*24*2)); 5 document.cookie = name + "=" + escape (value)+((expires == null) ? "" : ("; expires=" +LargeExpDate.toGMTString())); 6 7 }, 8 getCookie:function (c_name){ 9 if (document.cookie.length>0) 10 { 11 var c_start=document.cookie.indexOf(c_name + "=") 12 if (c_start!=-1) 13 { 14 c_start=c_start + c_name.length+1 15 var c_end=document.cookie.indexOf(";",c_start) 16 if (c_end==-1) c_end=document.cookie.length 17 return unescape(document.cookie.substring(c_start,c_end)) 18 } 19 } 20 return "" 21 },
2请求头部:
1.js
let queryParam = (name) => { // eval("Obj.data.e_id=111"); //动态添加对象属性 // console.log(Obj); var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); var r = window.location.search.substr(1).match(reg); if(r != null) return unescape(r[2]); return null; }
2.vue
import querystring from ‘querystring‘ //截取获取url的用户user_token var search = window.location.search; if(search.length > 0 && search[0] == ‘?‘){ search = search.slice(1); } var query = querystring.parse(search); var token = query.user_token;
3.localStorage
loginForm: { email: ‘‘, password: ‘‘ }, 存:window.localStorage.setItem(‘user‘,JSON.stringify(this.loginForm)); 取: window.localStorage.getItem(‘user‘);
标签:ken border translate cookie abs word port length href
原文地址:https://www.cnblogs.com/breakXu/p/10191847.html