【发布时间】:2018-10-11 06:03:38
【问题描述】:
有一个反应组件。需要在页面加载时打开引导模式。尝试使用 jQuery 和简单的 javascript,但没有成功。
反应组件:
import React, { Component } from 'react'
import $ from 'jquery'
class Login extends Component {
componentDidMount() {
// here I want to open modal
}
render() {
return (
<div className="modal fade WelcomeModal" id="WelcomeModal" tabIndex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div className="modal-dialog modal-dialog-centered" role="document">
<div className="modal-content">
<div className="modal-header">
<div className="camera-box">
<img alt="" src="/img/yellow-logo.svg"/>
<h5 className="modal-title" id="exampleModalLabel">Welcome to the Cozy App!</h5>
</div>
</div>
<div className="modal-body">
<p className="text-center">On the following screens weʼll ask you to register the Cozys in your home & adjust your temperature settings. Youʼll need the following information:</p>
</div>
</div>
</div>
</div>
)
}
}
【问题讨论】:
-
你不需要 jquery。您可以使用状态中的属性显示模式。
-
能发个例子吗!
标签: javascript jquery reactjs bootstrap-modal react-bootstrap4-modal