标签:name url参数 javascrip OLE ram 解析 gitbook pre tag
var url = ‘https://gitbook.cn/gitchat/geekbooks?tag=JavaScript&name=pwwu&age=24‘; var temp1 = url.split(‘?‘); var pram = temp1[1]; var keyValue = pram.split(‘&‘); var obj = {}; for (var i = 0; i<keyValue.length; i++){ var item = keyValue[i].split(‘=‘); var key = item[0]; var value = item[1]; obj[key] = value; } console.log(url); console.log(temp1); // [‘https://gitbook.cn/gitchat/geekbooks‘,‘tag=JavaScript&name=pwwu&age=24‘] console.log(pram); // tag=JavaScript&name=pwwu&age=24 console.log(keyValue); // [‘tag=JavaScript‘,‘name=pwwu‘,‘age=24‘] console.log(obj); // {tag:‘JavaScript‘,name:‘pwwu‘,age:‘24‘}
标签:name url参数 javascrip OLE ram 解析 gitbook pre tag
原文地址:https://www.cnblogs.com/aaaadioppa/p/14744434.html