【问题标题】:Is there a show attribute in react -popupreact -popup 中是否有 show 属性
【发布时间】:2020-01-03 01:27:51
【问题描述】:

react popup中有一个触发按钮,它有show属性吗?

<Popup trigger={<button> Trigger</button>} position="right center">
<div>Popup content here !!</div>
</Popup>

我的意思是,我的要求是在事件发生时显示弹出窗口(当我单击反应表中的单元格时,触发器会转到 onclick 函数,如果我可以在 onclick 中执行某些操作以触发弹出窗口)

类似:

<Popup show=this.state.showpopup position="right center">
<div>Popup content here !!</div>
</Popup>

this.state.showpopup 将通过 onclick 设置

【问题讨论】:

    标签: javascript reactjs popup


    【解决方案1】:

    弹出窗口有一个名为 open 的道具,它接受一个布尔值。 试试:

    open={this.state.showpopup}
    

    【讨论】:

      【解决方案2】:

      我认为您想在不使用触发道具的情况下显示弹出窗口, 试试这个

      function component() {
          const [showModal, setShowModal] = useState(false)
          return (
              <Fragment>
                    <button onClick={() => setShowModal(true)}>Trigger</button>
                    <Popup modal={showModal} position="right center">
                           <div>Popup content here !!</div>
                    </Popup>
              </Fragment>
          )
      }
      

      【讨论】:

        猜你喜欢
        • 2019-05-01
        • 1970-01-01
        • 1970-01-01
        • 2021-01-05
        • 2019-05-06
        • 2017-04-30
        • 1970-01-01
        • 2022-12-24
        • 2022-01-23
        相关资源
        最近更新 更多