日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

react跳转url,跳转外链,新页面打开页面

發布時間:2024/4/13 编程问答 37 豆豆
生活随笔 收集整理的這篇文章主要介紹了 react跳转url,跳转外链,新页面打开页面 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

react中實現在js中內部跳轉路由,有兩種方法。

方法一:

import PropTypes from 'prop-types'; export default class Header extends Component {static contextTypes = {router: PropTypes.object.isRequired,}constructor(props) {super(props);this.state = {keyword:"",channelList:[]};this.handleToSearch=this.handleToSearch.bind(this);}handleToSearch() {if(this.state.keyword){this.context.router.history.push(`/news_list/search/${this.props.channelId}/${this.state.keyword}`)}}render() {return (<div className="wrapper">小星星小星星</div> );} }

方法二:

this.props.history.push('/download')

跳轉到外鏈:

window.location.href = 'https://你的url'

?

在頁面中給一個按鈕綁定綁定跳轉,如果跳轉到項目的路由,引入react-router的Link

使用<Link to="/download">下載</Link> 形式跳轉,如果希望頁面從新頁面打開,加?

target="_blank"

如果跳轉到一個外鏈,使用a標簽,如果希望頁面從新頁面打開,除了加target,

target="_blank"

還要加一個rel:

<span><a href="https://internal.zhongwentoutiao.com/admin/news_list" target="_blank" rel="noopener noreferrer">管理員入口</a></span>

?

轉載于:https://www.cnblogs.com/beileixinqing/p/9529433.html

總結

以上是生活随笔為你收集整理的react跳转url,跳转外链,新页面打开页面的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。