Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

如当前路由地址为:http://localhost:8585/#/book
页面中有个<Link to="/book?id=1">《前端从入门到放弃》</Link>

如何在点击Link的时候让页面重载?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
3.7k views
Welcome To Ask or Share your Answers For Others

1 Answer

如果你用的react15.x的版本 可以参考react-router url参数更新
componentWillReceiveProps去控制

如果用的react16.x的版本 我觉得可以用useRef+useEffect去控制
useRef记录你旧的参数 useEffect去比对新的参数和旧的参数是不是有区别 再去页面重载

还是页面分开比较好 换个url去做新的事情


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...