本教程操作环境:windows10系统、react18版、dell g3电脑。
react 怎么实现跳转到新页面?
react 点击跳转新页面
跳转方法:
在前端的实战开发中我们需要用到框架的地方是比较广泛的,今天我们就来说说在“react 怎么点击跳转新页面?跳转方法!”吧!
方法一:
在原来页面打开一个新的页面,我们通过应用 ant 中的 button 组件;代码如下:
<button style={{backgroundcolor:'#f0f2f5'}} onclick={()=>{window.location.href="https://baidu.com"}} classname="r-button">
之后在通过 import {link} from 'react-router-dom' 这串代码就可以实现了,在原本页面新开一个页面。代码如下:
<link to="/new/login/"><button classname="e-button" type="primary">back to login page</button></link>
方法二:
本地页面通过点击跳转到新的页面,代码如下:
<button style={{backgroundcolor:'#f0f2f5'}} onclick={this.handle}classname="last-button">handle=()=>{ const w=window.open('about:blank'); w.location.href="www.baidu.com"}
总结:
以上就是一个有关于在“react 怎么点击跳转新页面?跳转方法!”的几个方法,当然如果你有更好的一个实现的方法还可以和大家一起分享噢!其他有关于 react 框架的知识我们都可以在 react 入门课程中进行购买学习,干货和实战一并拥有帮你快速提高。
推荐学习:《react视频教程》
以上就是react 怎么实现跳转到新页面的详细内容。
