1、安装js-cookie
2、import Cookies from ‘js-cookie‘
设置cookie
private domain: string = location.href.indexOf(‘ele.me‘) > -1 ? ‘.ele.me‘ : ‘.elenet.me‘ Cookies.set(‘WMUSS‘, res.WMUSS, { domain: this.domain, expires: 30 }) Cookies.set(‘OPENUSS‘, res.WMUSS, { domain: this.domain, expires: 30 })
3、删除cookie
let domain: string = location.href.indexOf(‘ele.me‘) > -1 ? ‘.ele.me‘ : ‘.elenet.me‘; Cookies.remove(‘WMSTOKEN‘, { domain: domain }); Cookies.remove(‘OUTER_AUTH_LOGIN‘, { domain: domain }); Cookies.remove(‘WMUSS‘, { domain: domain }); Cookies.remove(‘COFFEE_TOKEN‘, { domain: domain });