相关推荐:
本文主要和大家分享vue.js设置cookie实例分享。希望能帮助到大家。
//设置cookie<存>setCookie: function (cname, cvalue, exdays) { var d = new Date(); d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000)); var expires = "expires=" + d.toUTCString(); console.info(cname + "=" + '111' + "; " + expires); document.cookie = cname + "=" + cvalue + "; " + expires; },//获取cookiegetCookie: function (cname) { var arr, reg = new RegExp("(^| )" + cname + "=([^;]*)(;|$)"); if (arr = document.cookie.match(reg)) return (arr[2]); else return null; },
<br/>
删除cookie
delCookie: function (name) {
var exp = new Date(); exp.setTime(exp.getTime() - 1); var cval = getCookie(name); if (cval != null) document.cookie = name + "=" + cval + ";expires=" + exp.toGMTString(); }
相关推荐:
Atas ialah kandungan terperinci vue.js设置cookie实例分享. Untuk maklumat lanjut, sila ikut artikel berkaitan lain di laman web China PHP!