获取浏览器地址栏字符串参数
作者:互联网
// ?name='?post=1111&action=add"
1 var urlParams = new URLSearchParams(window.location.search); 2 console.log(urlParams.has('post')); // true 3 console.log(urlParams.get('action')); // add 4 console.log(urlParams.getAll('action')); // ["add"] 5 console.log(urlParams.toString()); // post=1111&action=add 6 console.log(urlParams.append('active', 100)); // post=1111&action=add&active=100 7 console.log(urlParams.get('active')); // 100
注释:URLSearchParams存在兼容性问题
标签:浏览器,log,console,action,add,字符串,urlParams,post,地址栏 来源: https://www.cnblogs.com/liushihong21/p/11275765.html