<small id='ZFgrK'></small><noframes id='ZFgrK'>

  • <tfoot id='ZFgrK'></tfoot>
    <i id='ZFgrK'><tr id='ZFgrK'><dt id='ZFgrK'><q id='ZFgrK'><span id='ZFgrK'><b id='ZFgrK'><form id='ZFgrK'><ins id='ZFgrK'></ins><ul id='ZFgrK'></ul><sub id='ZFgrK'></sub></form><legend id='ZFgrK'></legend><bdo id='ZFgrK'><pre id='ZFgrK'><center id='ZFgrK'></center></pre></bdo></b><th id='ZFgrK'></th></span></q></dt></tr></i><div id='ZFgrK'><tfoot id='ZFgrK'></tfoot><dl id='ZFgrK'><fieldset id='ZFgrK'></fieldset></dl></div>

        <bdo id='ZFgrK'></bdo><ul id='ZFgrK'></ul>
      <legend id='ZFgrK'><style id='ZFgrK'><dir id='ZFgrK'><q id='ZFgrK'></q></dir></style></legend>

        使用 Javascript 和 CSS 的 ReactJs 模态

        时间:2023-09-04
      1. <i id='AuB9N'><tr id='AuB9N'><dt id='AuB9N'><q id='AuB9N'><span id='AuB9N'><b id='AuB9N'><form id='AuB9N'><ins id='AuB9N'></ins><ul id='AuB9N'></ul><sub id='AuB9N'></sub></form><legend id='AuB9N'></legend><bdo id='AuB9N'><pre id='AuB9N'><center id='AuB9N'></center></pre></bdo></b><th id='AuB9N'></th></span></q></dt></tr></i><div id='AuB9N'><tfoot id='AuB9N'></tfoot><dl id='AuB9N'><fieldset id='AuB9N'></fieldset></dl></div>
        <tfoot id='AuB9N'></tfoot>
        • <bdo id='AuB9N'></bdo><ul id='AuB9N'></ul>

        • <legend id='AuB9N'><style id='AuB9N'><dir id='AuB9N'><q id='AuB9N'></q></dir></style></legend>
                  <tbody id='AuB9N'></tbody>

                <small id='AuB9N'></small><noframes id='AuB9N'>

                  本文介绍了使用 Javascript 和 CSS 的 ReactJs 模态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  如何在 reactjs 模态窗口后面加上 body 结束标签来设置带有 body 标签的绝对模态定位.

                  How to append reactjs modal window with body end tag to set the modal positioning absolute with body tag.

                  这是在另一个组件中添加的示例.

                  Here is example added inside the another component.

                  <div className="modal">
                    <p>Model Pop-up <button onClick={this.handleClick}>here</button></p>
                      <div id="js-modal-inner" className="modal">
                        <div className="modal__content js-dialog">
                          <a className="modal__close" onClick={this.handleClose}>&times;</a>
                          <header className="modal__header">
                            <h2 className="modal__title">Split Ticket:</h2>
                          </header>
                          <div className="modal__content--inner">
                            {this.props.children}
                          </div>
                        </div>
                      </div>
                      <div className="modal__overlay js-fade"></div>
                    </div> 
                  

                  推荐答案

                  这在 react 中通常被称为层".见这个小提琴

                  This is usually referred to as 'layers' in react. See this fiddle

                  /** @jsx React.DOM */
                  
                  var ReactLayeredComponentMixin = {
                      componentWillUnmount: function() {
                          this._unrenderLayer();
                          document.body.removeChild(this._target);
                      },
                      componentDidUpdate: function() {
                          this._renderLayer();
                      },
                      componentDidMount: function() {
                          // Appending to the body is easier than managing the z-index of everything on the page.
                          // It's also better for accessibility and makes stacking a snap (since components will stack
                          // in mount order).
                          this._target = document.createElement('div');
                          document.body.appendChild(this._target);
                          this._renderLayer();
                      },
                      _renderLayer: function() {
                          // By calling this method in componentDidMount() and componentDidUpdate(), you're effectively
                          // creating a "wormhole" that funnels React's hierarchical updates through to a DOM node on an
                          // entirely different part of the page.
                          React.renderComponent(this.renderLayer(), this._target);
                      },
                      _unrenderLayer: function() {
                          React.unmountComponentAtNode(this._target);
                      }
                  };
                  
                  var Modal = React.createClass({
                      killClick: function(e) {
                          // clicks on the content shouldn't close the modal
                          e.stopPropagation();
                      },
                      handleBackdropClick: function() {
                          // when you click the background, the user is requesting that the modal gets closed.
                          // note that the modal has no say over whether it actually gets closed. the owner of the
                          // modal owns the state. this just "asks" to be closed.
                          this.props.onRequestClose();
                      },
                      render: function() {
                          return this.transferPropsTo(
                              <div className="ModalBackdrop" onClick={this.handleBackdropClick}>
                                  <div className="ModalContent" onClick={this.killClick}>
                                      {this.props.children}
                                  </div>
                              </div>
                          );
                      }
                  });
                  
                  var ModalLink = React.createClass({
                      mixins: [ReactLayeredComponentMixin],
                      handleClick: function() {
                          this.setState({shown: !this.state.shown});
                      },
                      getInitialState: function() {
                          return {shown: false, ticks: 0, modalShown: false};
                      },
                      componentDidMount: function() {
                          setInterval(this.tick, 1000);
                      },
                      tick: function() {
                          this.setState({ticks: this.state.ticks + 1});
                      },
                      renderLayer: function() {
                          if (!this.state.shown) {
                              return <span />;
                          }
                          return (
                              <Modal onRequestClose={this.handleClick}>
                                  <h1>Hello!</h1>
                                  Look at these sweet reactive updates: {this.state.ticks}
                              </Modal>
                          );
                      },
                      render: function() {
                          return <a href="javascript:;" role="button" onClick={this.handleClick}>Click to toggle modal</a>;
                      }
                  });
                  
                  React.renderComponent(<ModalLink />, document.body);
                  

                  这篇关于使用 Javascript 和 CSS 的 ReactJs 模态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:使用 iframe URL 的 jQuery UI 对话框 下一篇:页面加载时立即显示 JQuery 对话框

                  相关文章

                  最新文章

                  1. <tfoot id='e186c'></tfoot>

                    <legend id='e186c'><style id='e186c'><dir id='e186c'><q id='e186c'></q></dir></style></legend>
                    • <bdo id='e186c'></bdo><ul id='e186c'></ul>
                  2. <i id='e186c'><tr id='e186c'><dt id='e186c'><q id='e186c'><span id='e186c'><b id='e186c'><form id='e186c'><ins id='e186c'></ins><ul id='e186c'></ul><sub id='e186c'></sub></form><legend id='e186c'></legend><bdo id='e186c'><pre id='e186c'><center id='e186c'></center></pre></bdo></b><th id='e186c'></th></span></q></dt></tr></i><div id='e186c'><tfoot id='e186c'></tfoot><dl id='e186c'><fieldset id='e186c'></fieldset></dl></div>

                  3. <small id='e186c'></small><noframes id='e186c'>