测试JS中是否存在任何Url参数

时间:2020-01-25 13:02:55

标签: javascript

我需要测试是否存在任何个网址参数。它们的键和值并不重要。我设法在循环URLSearchParams上使用entries()

const urlParams = new URLSearchParams(window.location.search);

let thereAreUrlParams = false;
for (const X of urlParams.entries()) {
    thereAreUrlParams = true
}

我的问题:有更好或更干净的方法吗? 感觉应该有,但我根本找不到。

0 个答案:

没有答案
相关问题