如何通过a标签 里的点击事件οnclick 把JSON数据里的list传过去
这样?https://www.baidu.com/?q=[{%22a%22:1,%22b%22:2},{%22a%22:1,%22b%22:2}]
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<a href="javascript:void(0);" onclick="JsonQuery()">baidu</a>
<script>
function JsonQuery() {
var json = [
{
a: 1,
b: 2
},
{
a: 1,
b: 2
}
]
var q = JSON.stringify(json);
window.open(`http://baidu.com?q=${q}`)
}
</script>
</body>
</html>