我試圖測試出旋轉木馬,但是當我加載頁面時它是空白的。React Bootstrap組件不顯示
我用npm安裝了反應引導程序。
Carousal代碼是https://react-bootstrap.github.io/components.html#media-content。我看着我的Web控制檯,我也沒有任何警告或錯誤。
carousal.js
import React, { Component } from 'react';
import {Carousel} from 'react-bootstrap';
class carousel extends Component {
render() {
return (
<Carousel>
<Carousel.Item>
<img width={900} height={500} alt="900x500" src={require('./images/cs_logo.png')}/>
<Carousel.Caption>
<h3>First slide label</h3>
<p>Nulla vitae elit libero, a pharetra augue mollis interdum.</p>
</Carousel.Caption>
</Carousel.Item>
<Carousel.Item>
<img width={900} height={500} alt="900x500" src={require('./images/cs_logo.png')}/>
<Carousel.Caption>
<h3>Second slide label</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
</Carousel.Caption>
</Carousel.Item>
<Carousel.Item>
<img width={900} height={500} alt="900x500" src={require('./images/cs_logo.png')}/>
<Carousel.Caption>
<h3>Third slide label</h3>
<p>Praesent commodo cursus magna, vel scelerisque nisl consectetur.</p>
</Carousel.Caption>
</Carousel.Item>
</Carousel>
);
}
}
export default carousel;
index.js
import React from 'react';
import ReactDOM from 'react-dom';
import carousel from './carousal';
ReactDOM.render(<carousel/>,document.getElementById('root'));
的index.html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/latest/css/bootstrap.min.css">
<title>title</title>
</head>
<body>
<header>
<div id="nav"></div>
</header>
<div id="root" style="text-align: center; float: none"></div>
</body>
</html>
我嘗試添加它,現在我得到了控制檯 這個錯誤「的反應,bootstrap.js:2037遺漏的類型錯誤:無法讀取未定義(...)出口.__ esModule @反應,bootstrap.js的特性‘PropTypes’:2037__webpack_require__ @ react-bootstrap.js:30exports .__ esModule @ react-bootstrap.js:430__webpack_require__ @ react-bootstrap.js:30exports .__ esModule @ react-bootstrap.js:62__webpack_require__ @ react-bootstrap.js:30exports .__ esModule @ react-bootstrap .js:50(匿名函數)@ react-bootstrap.js:53webpackUniversalModuleDefinition @ react-bootstrap.js:9(匿名函數)@ react-bootstrap.js:10「 – user3034572