所以我一直在尝试从我的 jsx 我的 html 文件中导入图像轮播。我已将必要的脚本添加到我的 .html 和“npm install react-slick carousel”中。加载浏览器后什么都没有出现。帮小弟解围。到目前为止,这是我的代码。
HTML 文件
<!DOCTYPE html> <html lang="en"> <head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<script src="https://unpkg.com/react@15.6.2/dist/react.js"></script>
<script src="https://unpkg.com/react-dom@15.6.2/dist/react-dom.js"></script>
<script src="https://unpkg.com/babel-standalone@6.15.0/babel.min.js"></script>
<title>Friend With Benefits</title> </head> <body>
<header>
<div id="fwb">
<button onclick="window.location.reload();">Friend With Benefits (FWB)</button>
</div>
<div class="register">
<button>Sign Up</button>
</div>
<div>
<button>Login</button>
</div>
</header>
<div class="carousel">
<script src="carousel.jsx"></script>
</div>
<button id="prevBtn;">Prev</button>
<button id="nextBtn">Next</button>
<div class="profile">
SLIDESHOW
</div>
<div class="gym">
<img src="">
<blockquote>
FWB is collaborating with Gold's Gym, American Family, and YouFit. If a friend
brings in enough people to a gym they will be rewarded points towards their gym membership.<br>
Points can earn a friend perks such as: discounts, complementary gym accessories, and free membership
for a month.
</blockquote>
</div>
<div class="cost">
<img src="">
<blockquote>The yearly cost for FWB is only $50.<br>Free trial for the first month. Will notify three days before trial is over to
avoid automated payment.</blockquote>
</div>
<div class="quote">
SLIDESHOW
</div>
<footer class="footer">
</footer>
</body> </html>
JSX 文件
import React, { Component } from "react"; import Slider from
"react-slick";
export default class SimpleSlider extends Component { render() {
const settings = {
dots: true,
infinite: true,
speed: 500,
slidesToShow: 1,
slidesToScroll: 1
};
return (
<div>
<Slider {...settings}>
<div><img src="partner1.png" alt="one"/></div>
<div><img src="partner2.jpg" alt="two"/></div>
<div><img src="partner3.jpg" alt="three"/></div>
<div><img src="partner4.jpg" alt="four"/></div>
<div><img src="partner5.jpg" alt="five"/></div>
<div><img src="partner6.jpg" alt="six"/></div>
</Slider>
</div>
); } }