js实现跳转传参

小董大咖 · 收录于 2023-09-24 03:59:41 · source URL

第一个页面需要传递的

window.location.href="search-one.html?"+val//跳转到自己需要的文件

在第2个页面接收

// 接取参数
let num = window.location.search.slice(1);
let arr = decodeURI(num)//使用decode将传递过来的参数进行拆解
console.log(arr);