📜  在 javascript 代码示例中获取 cookie 值

📅  最后修改于: 2022-03-11 15:03:48.401000             🧑  作者: Mango

代码示例3
function getCookie(cookie, name) {
  const q = {}
  cookie?.replace(/\s/g, '')
    .split(';')
    .map(i=>i.split('='))
    .forEach(([key, value]) => {
      q[key] = value
    })
  return q[name]??null;
}