我想使用react-slik。
https://github.com/akiran/react-slick
import Slider from "react-slick";
我的设置:
var settings = {
slidesToShow: 1,
slidesToScroll: 1,
arrows: true,
autoplay: true,
centerMode: true,
variableWidth: true,
centerPadding: '110px',
prevArrow: '<button type="button" class="slick-next"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-chevron-left"><polyline points="15 18 9 12 15 6"></polyline></svg></button>',
nextArrow: '<button type="button" class="slick-prev"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-chevron-right"><polyline points="9 18 15 12 9 6"></polyline></svg></button>',
responsive: [
{
breakpoint: 768,
settings: {
slidesToShow: 1,
slidesToScroll: 1,
centerMode: false,
variableWidth: false,
variableHeight: false,
arrows: false
}
}
]
};
它有效:
<Slider {...settings}>
<div>
<h1>masoud</h1>
</div>
</Slider>
但它不起作用:
<Slider {...settings}>
<div>
<h1>masoud</h1>
</div>
<div>
<h1>masoud</h1>
</div>
</Slider>
package.json
:
"react-slick": "^0.22.3",
错误:
Invariant Violation: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in.
[0] at invariant