javascript - 使用 react-bootstrap 未显示模态
问题描述
我是 react 新手,这里我使用 react bootstrap 。
所以,我的组件就像
import React from 'react';
import { Button } from 'react-bootstrap';
import { Modal } from 'react-bootstrap';
import { Container, Row, Col, Image } from 'react-bootstrap';
class ErrorComponent extends React.Component {
constructor(props, context) {
super(props, context);
this.state = {
show: props.show,
};
}
render() {
return (
<Modal
{...this.props}
bsSize="large"
aria-labelledby="contained-modal-title-lg"
>
<Modal.Header closeButton>
<Modal.Title id="contained-modal-title-lg">
cndjcndcndncjcdcd
</Modal.Title>
</Modal.Header>
<Modal.Body>
cdnjcdncdcnc
</Modal.Body>
<Modal.Footer>
</Modal.Footer>
</Modal>
);
}
}
export default ErrorComponent;
这是从父组件渲染的,
render() {
let lgClose = () => this.setState({ showModal: false });
return (
<div>
<div className="questionLevelIndication">
<span className="levelIndicatorBtn backgroundColorForLow">
1
</span>
<label className="levelIndicationLabel">
Low Difficulty Level - Maximum 6 questions
</label>
</div>
{(this.props.lowData) && this.props.lowData.Low.length > 0 && this.props.lowData.Low.map(data => (
<LowRow technologies={this.state.technologies} onChange={this.onchange.bind(this)} data={data} key={data.id} onAddRow={this.onaddRow.bind(this)} onRemoveRow={this.onRemoveRow.bind(this)} />
))}
<ErrorComponent show={this.state.showModal} onHide={lgClose} />
</div>
)
}
}
但是,我仍然看不到模型。这有什么不透明相关的问题吗?任何人都可以建议我解决这个问题吗?2.如何使该模态垂直居中?任何提示都会有所帮助。
解决方案
推荐阅读
- clojurescript - 分组数据矢量图结构路径的位置键
- java - Java Jackson Streaming API 在创建 JSON 时识别当前上下文(检查对象、数组等)
- c# - 如何从 .NET Standard 库中的类生成 XML 模式?
- java - 为使用 @ConfigurationProperties 注释的类获取 NoSuchBeanDefinitionException
- javascript - 反应状态不使用钩子更新
- scala - 如何交换到 Seq 中的元素
- javascript - 如何独立触发 NGRX Selector foreach 子组件
- python - Django-RQ 很难将项目添加到 Django 模型
- angular - 为什么每次向我的 Angular 项目添加新的顺风类时都必须重新服务我的项目?
- tensorflow - 从 tfrecords 错误解码 JPEG:ValueError:形状必须为 0 级,但对于具有输入形状的“DecodeJpeg”(操作:“DecodeJpeg”)为 1 级:[?]