1、页面点击本地页面打开新页面
引入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>
带参跳转 引入import { Link} from 'umi';
<Link to={{pathname:`/device/enroll-record?account=${row.account}`}} target="_blank">
<Button className="enroll_btn" size="small" >打卡记录</Button>
</Link>
页面参数获取:this.props.location.query.account
注意:
target="_blank" 表示新打开一个窗口跳转,传参时必须使用?拼接参数
如果不使用target="_blank" 表示本页面跳转,to={{pathname:'/device/enroll-record‘,query:{account:row.account}}}
2、本地页面不变跳转到新的页面
<Button style={{backgroundColor:'#F0F2F5'}}
onClick={this.handle}
className="last-button"
>
handle=()=>{
const w=window.open('about:blank');
w.location.href="www.baidu.com"
}
3、history.push() 跳转
this.props.history.push(url)