cdn引入vue形式的url参数获取方法

vue

 //获取url参数

get_query_string: function(name) {

var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");

var r = window.location.search.substr(1).match(reg); //search,查询?后面的参数,并匹配正则

if (r != null) return decodeURI(r[2]);

return null;

},

   //设置cookie

setCookie(cname, cvalue, exdays) {

var d = new Date();

d.setTime(d.getTime() + exdays * 24 * 60 * 60 * 1000);

var expires = "expires=" + d.toUTCString();

document.cookie = cname + "=" + cvalue + "; " + expires;

},

//获取cookie

getCookie(cname) {

var name = cname + "=";

var ca = document.cookie.split(";");

for (var i = 0; i < ca.length; i++) {

var c = ca[i];

while (c.charAt(0) == " ") c = c.substring(1);

if (c.indexOf(name) != -1) {

return c.substring(name.length, c.length);

}

}

return "";

},

//清除cookie

clearCookie(cname) {

this.setCookie(cname, "", -1);

}

以上是 cdn引入vue形式的url参数获取方法 的全部内容, 来源链接: utcz.com/z/378188.html

回到顶部