JS 获取URL 某个参数

// 假设 URL 为 https://example.com/?id=123&name=John
const urlParams = new URLSearchParams(window.location.hash);
const id = urlParams.get('id'); // 返回 "123"
const name = urlParams.get('name'); // 返回 "John"