【发布时间】:2021-11-22 13:36:35
【问题描述】:
当点击“搜索”时,下一页由以下代码加载。
import React from "react";
import { Link } from "react-router-dom";
function name(){
return(
<div className="search">
<input type="text"placeholder="city name"></input>
<input type="text"placeholder="number of people"></input>
<p><Link to="/nextpage">Search</Link</p>
</div>
)
}
我想获取这些输入字段的数据以获取 api,使用该数据在下一页制作卡片。 怎么做?
【问题讨论】:
-
可以使用“历史”拉取url的查询字符串参数
-
可以通过params传递。这是一个很好的答案stackoverflow.com/a/30115524/3508399
标签: reactjs react-native react-hooks react-router