反应按钮点击重定向页面 [英] react button onClick redirect page

查看:30
本文介绍了反应按钮点击重定向页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 React 和引导程序开发 Web 应用程序.在应用 onClick 按钮时,我很难让我的页面重定向到另一个页面.如果在 href 之后,我无法转到另一页.

那么请您告诉我是否需要使用 react-navigation 或其他方式使用 Button onClick 导航页面?

import React, { Component } from 'react';import { Button, Card, CardBody, CardGroup, Col, Container, Input, InputGroup, InputGroupAddon, InputGroupText, Row, NavLink } from 'reactstrap';类 LoginLayout 扩展组件 {使成为() {返回 (<div className="app flex-row align-items-center"><容器>...<行><Col xs="6"><按钮颜色="primary" className="px-4">登录</按钮></Col><Col xs="6" className="text-right"><Button color="link" className="px-0">忘记密码?</Button></Col></行>...</容器>

);}}

解决方案

不要使用按钮作为链接.而是使用样式为按钮的链接.

注册

I am working on web application using React and bootstrap. When it comes to applying button onClick, it takes me hard time to let my page being redirect to another. if after a href , I cannot go the another page.

So would you please tell me is there any need for using react-navigation or other to navigate the page using Button onClick ?

import React, { Component } from 'react';
import { Button, Card, CardBody, CardGroup, Col, Container, Input, InputGroup, InputGroupAddon, InputGroupText, Row, NavLink  } from 'reactstrap';

class LoginLayout extends Component {

  render() {
    return (
 <div className="app flex-row align-items-center">
        <Container>
     ...
                    <Row>
                      <Col xs="6">                      
                        <Button color="primary" className="px-4">
                            Login
                         </Button>
                      </Col>
                      <Col xs="6" className="text-right">
                        <Button color="link" className="px-0">Forgot password?</Button>
                      </Col>
                    </Row>
               ...
        </Container>
      </div>
    );
  }
}

解决方案

Don't use a button as a link. Instead, use a link styled as a button.

<Link to="/signup" className="btn btn-primary">Sign up</Link>

这篇关于反应按钮点击重定向页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆