我正在使用ngx-cookie发送,但找不到如何删除浏览器中现有的cookie。有什么想法吗?
文档:(https://tinesoft.github.io/ngx-cookieconsent/doc/index.html) (https://github.com/tinesoft/ngx-cookieconsent)
Stackblitz https://stackblitz.com/github/tinesoft/ngx-cookieconsent/tree/master/demo
ty
发布于 2021-01-03 02:41:44
我认为这个库不是为了这个目的,但是你可以用原生Javascript删除任何cookie
function delete_cookie( name, path, domain ) {
if( get_cookie( name ) ) {
document.cookie = name + "=" +
((path) ? ";path="+path:"")+
((domain)?";domain="+domain:"") +
";expires=Thu, 01 Jan 1970 00:00:01 GMT";
}
}
function get_cookie(a) {
var b = document.cookie.match('(^|;)\\s*' + a + '\\s*=\\s*([^;]+)');
return b ? b.pop() : '';
}https://stackoverflow.com/questions/65542663
复制相似问题