首页 > 解决方案 > React 如何将索引传递到地图功能之外?

问题描述

只是在旋转木马上工作。只是在结束时尝试禁用按钮。disabled={ index === 0 } 由于超出地图范围而无法正常工作。感谢您的帮助。

<Carousel settings={ settings } ref={ ref }>
    {slides.map((el, index) => (
      <SlideGallery key={ index }>
        <SlideItems style={{ background: el.imgUrl }}>
          <picture><img src={ el.imgUrl } alt=''></img></picture>
          <SlideInner>
            <h3>{el.review}</h3>
            <p></p>
            <p>UserName</p>
          </SlideInner>
        </SlideItems>
      </SlideGallery>
    ))}
  </Carousel>
  <ButtonWrapper>
    <PrevButton onClick={ prevSlide } disabled={ index === 0 }><ChevronLeft/></PrevButton>
    <NextButton onClick={ nextSlide }><ChevronRigt/></NextButton>
  </ButtonWrapper>

标签: reactjsfunction

解决方案


推荐阅读