【问题标题】:React bootstrap overlay rootclose not working反应引导覆盖rootclose不起作用
【发布时间】:2016-07-07 21:01:56
【问题描述】:

我遵循与引导网站中的叠加示例完全相同的样式,并且在网站上,当我尝试添加 rootclose 时,它​​无法正常工作(点击屏幕其他位置时叠加不会关闭),并且我自己的工作也一样

const Example = React.createClass({
  getInitialState() {
    return { show: true };
  },

  toggle() {
    this.setState({ show: !this.state.show });
  },

  render() {
    const style = {
      position: 'absolute',
      backgroundColor: '#EEE',
      boxShadow: '0 5px 10px rgba(0, 0, 0, 0.2)',
      border: '1px solid #CCC',
      borderRadius: 3,
      marginLeft: -5,
      marginTop: 5,
      padding: 10
    };

    return (
      <div style={{ height: 100, position: 'relative' }}>
        <Button ref="target" onClick={this.toggle}>
          I am an Overlay target
        </Button>

        <Overlay
          show={this.state.show}
          onHide={() => this.setState({ show: false })}
          placement="right"
          container={this}
          rootclose
          target={() => ReactDOM.findDOMNode(this.refs.target)}
        >
          <div style={style}>
            <strong>Holy guacamole!</strong> Check this info.
          </div>
        </Overlay>
      </div>
    );`enter code here`
  }
});

ReactDOM.render(<Example/>, mountNode);

【问题讨论】:

  • 试试rootClose 而不是rootclose
  • 遇到同样的问题并意识到这是因为我在触发按钮上使用了onTouchTap 而不是onClick

标签: reactjs overlay react-bootstrap


【解决方案1】:

驼峰式。并提供布尔值。

rootClose={true}

【讨论】:

    猜你喜欢
    • 2021-09-27
    • 2016-12-22
    • 2019-08-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-07-18
    • 2019-01-26
    • 1970-01-01
    相关资源
    最近更新 更多