信息管理系统中 index.html 中的用户数据传到 update.html 的input中
实现方法:
const tr = document.createElement('tr')
tr.innerHTML = `
<td>${item.id}</td>
<td>${item.username}</td>
<td>${item.password}</td>
<td>
<a href="./update.html?id=${item.id}&username=${item.username}&password=${item.password}" class='update'>编辑</a>
<a href="" class='delete'>删除</a>
</td>
`
将值放在a标签的href中 用?隔开,这样跳转链接(update.html)中含有所需要的信息
在update.html中
var url =new URLSearchParams((document.location.search.substring(1))) //获取当前页面路径
let id = url.get('id')
URLSearchParams()用法参考网站js - 获取url中的参数 (URLSearchParams ) - 掘金
ps:还可以用浏览器的本地存储