gpt4 book ai didi

javascript - 响应属性不适用于 react-slick

转载 作者:太空宇宙 更新时间:2023-11-04 06:32:39 25 4
gpt4 key购买 nike

我想在小型设备上更改 sliderToShow 属性,但 responsive 属性不起作用。

let settings_3 = {
dots: false,
autoplay: false,
autoplaySpeed: 3000,
slidesToShow: 3,

responsive: [{
breakpoint: 600,
settings_3: {
slidesToShow: 2,
slidesToScroll: 2,
initialSlide: 2
}
}]
};

最佳答案

settings_3 更改为 responsive[] 中的 settings。 slick 中没有 settings_3 属性:

class SimpleSlider extends React.Component {
render() {
let settings_3 = {
dots: false,
autoplay: false,
autoplaySpeed: 3000,
slidesToShow: 3,

responsive: [{
breakpoint: 600,
settings: {
slidesToShow: 2,
slidesToScroll: 2,
initialSlide: 2
}
}]
};
return (
<Slider {...settings_3}>
<div>
<h3>1</h3>
</div>
<div>
<h3>2</h3>
</div>
<div>
<h3>3</h3>
</div>
<div>
<h3>4</h3>
</div>
<div>
<h3>5</h3>
</div>
<div>
<h3>6</h3>
</div>
</Slider>
);
}
}

ReactDOM.render( <SimpleSlider/> ,
document.getElementById('root')
);
#root{
text-align: center;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.6.0/slick.min.css" rel="stylesheet" />

<link href="https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.6.0/slick-theme.min.css" rel="stylesheet" />

<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react.min.js"></script>

<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react-dom.min.js"></script>

<script src="https://cdnjs.cloudflare.com/ajax/libs/react-slick/0.13.1/react-slick.js"></script>

<div id='root'></div>

关于javascript - 响应属性不适用于 react-slick,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54515714/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com