function getCookie(name) {
if (document.cookie.length > 0) {
const end = `${name}=`
const cal = document.cookie.split(';')
for (let i = 0; i < cal.length; i += 1) {
const str = cal[i].trim()
if (str.substring(0,end.length) === end) return str.substring(end.length,str.length)
}
}
return '';
}
来源:CSDN
作者:weixin_44953227
链接:https://blog.csdn.net/weixin_44953227/article/details/103926299