# 前端location使用

# 1. 当前URL新增query参数

const url = new URL(window.location.href);
url.searchParams.set('newParam', 'newValue');
// 更新浏览器地址栏
window.history.pushState({}, '', url);
// 刷新页面
window.location.reload();
1
2
3
4
5
6
Last Updated: 7/3/2025, 9:57:44 PM