照着官方的栗子来的
<Link to={{ pathname: '/user/bob', query: { showAge: true } }} activeClassName="active">Bob With Query Params</Link>
但是点击的时候浏览器却提示
Warning: Failed propType: Invalid prop to
of type object
supplied to Link
, expected string
. Check the render method of app
.
换成 to=“/”就没问题了,but why?to后面只能接字符串不能是变量,那官方的栗子是怎么回事呢?求助啊大大们...
检查下你安装的 react-router 的版本,给 to 传 object 是 2.0 才这样的。2.0 以下需要传 string。