首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >为什么我的模式不会出现在React Bootstrap的屏幕上?

为什么我的模式不会出现在React Bootstrap的屏幕上?
EN

Stack Overflow用户
提问于 2018-06-06 02:54:49
回答 1查看 54关注 0票数 0

正如问题所述,我正在尝试为我的React项目创建一个简单的Modal with Bootstrap。然而,在我点击了应该激活Modal的按钮后,模式无法出现。

这是我的LoginPage.js的代码。这是在我的index.js文件中通过ReactDOM.render呈现的组件。

import React from 'react';
import { Button, ButtonToolbar, Modal } from 'react-bootstrap';
class LoginPage extends React.Component {
    constructor(props, context) {
      super(props, context);

      this.handleShow = this.handleShow.bind(this);
      this.handleClose = this.handleClose.bind(this);

      this.state = {
        show: false,
      };
    }

    handleClose() {
      this.setState({ show: false });
    }

    handleShow() {
      this.setState({ show: true });
    }

    render() {
      return (
        <div>
        <p>Click to get the full Modal experience!</p>
        <Button bsStyle="primary" bsSize="large" onClick={this.handleShow}>
          Launch demo modal
        </Button>

        <Modal show={this.state.show} onHide={this.handleClose}>
          <Modal.Header closeButton>
            <Modal.Title>Modal heading</Modal.Title>
          </Modal.Header>
          <Modal.Body>
            <h4>Text in a modal</h4>
            <p>
              Duis mollis, est non commodo luctus, nisi erat porttitor ligula.
            </p>
          </Modal.Body>
          <Modal.Footer>
            <Button onClick={this.handleClose}>Close</Button>
          </Modal.Footer>
        </Modal>
      </div>
      );
    }
  }

export default LoginPage;

当我尝试在浏览器上运行它时,出现的内容是:how it appears on my browser。单击该按钮绝对不会执行任何操作。没有来自控制台的错误,并且在其他浏览器上不起作用。我已经安装了bootstrap,bootstrap react,并在我的JSON文件中将其作为依赖项列出。谢谢你的帮助!

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-06-06 04:27:57

我相信隐藏和展示模式的道具是isOpen

reactstrap.Modals

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50707121

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档