我无法将当前和总数量的幻灯片显示在slick.js幻灯片下方.谢谢你的帮助!!
$('.recipeThumbs').slick({
dots: true,
arrows: true,
slidesToShow: 4,
slidesToScroll: 4,
infinite: true,
responsive: [
{
breakpoint: 768,
settings: {
dots: false,
arrows: true,
centerMode: true,
centerPadding: '40px',
slidesToShow: 2,
slidesToScroll: 1
}
},
{
breakpoint: 480,
settings: {
dots: false,
arrows: true,
centerMode: true,
centerPadding: '40px',
slidesToShow: 1,
slidesToScroll: 1
}
}
]
});
Run Code Online (Sandbox Code Playgroud) 我是React.js的新手.我正试图让左侧导航系统坚持滚动.由于某种原因,下面的代码滚动时导致以下错误:
未捕获的TypeError:this.setState不是函数
任何帮助都会很棒!谢谢
class Sticky extends React.Component {
constructor(props) {
super(props);
this.state = {
scrollingLock: false
};
}
componentDidMount(){
window.addEventListener('scroll', this.handleScroll);
}
componentWillUnmount() {
window.removeEventListener('scroll', this.handleScroll);
}
handleScroll() {
if (window.scrollY > 100) {
console.log("should lock");
this.setState({
scrollingLock: true
});
} else if (window.scrollY < 100) {
console.log("not locked" );
this.setState({
scrollingLock: false
});
}
}
render() {
return (
<div style={{ width: "100%", position: this.state.scrollingLock ? "fixed" : "relative"}}>
{this.props.children}
</div>
)
}
}
export default Sticky;
Run Code Online (Sandbox Code Playgroud)