登录
读取和设置cookie:
// 读取 cookie
export function getCookie(key) {
var result = '';
if (document.cookie.length > 0) {
var arr = document.cookie.split('; ');
for (var i = 0; i < arr.length; i++) {
var arr2 = arr[i].split('=');
if (arr2[0] === key) {
result = arr2[1];
}
}
}
return result;
}
// 设置 cookie
export function setCookie(key, value) {
window.document.cookie = key + '=' + value + ';path=/; ' + ';';
}