js中怎么获取url中的参数?比如说获取https://q.zhixing.co/?page=2中的page
参数。
const params = new URLSearchParams(window.location.search);
const page = params.get('page');
或者
const params = new Proxy(new URLSearchParams(window.location.search), {
get: (searchParams, prop) => searchParams.get(prop),
});
const page = params.page;
内容