js 根据 key 获取 cookie 的值
/**
* 获取指定的cookie
* @param {String} key cookie的key
* @returns {String}
*/
export function getCookie(key) {
const cookie = document.cookie.split(';')
for (let i = 0, len = cookie.length; i < len; i++) {
const cur = cookie[i].split('=')
if (key === cur[0]) {
return cur[1]
}
}
return ''
}