3

我想把我所有的React-slick slides都包li起来ul。我浏览了文档,发现slideprop 可用于更改container元素。它需要一个包装元素名称为string. 默认值为div,我将其更改为,ul但我仍然将 div 作为容器div

class App extends Component {
  render() {
    let settings = {
      dots: true,
      infinite: true,
      speed: 500,
      slidesToShow: 1,
      slidesToScroll: 1,
      slide: "ul"
    };
    return (
      <Slider {...settings}>
        <li>
          <h3>1</h3>
        </li>
        <li>
          <h3>2</h3>
        </li>
        <li>
          <h3>3</h3>
        </li>
        <li>
          <h3>4</h3>
        </li>
        <li>
          <h3>5</h3>
        </li>
        <li>
          <h3>6</h3>
        </li>
      </Slider>
    );
  }
}

Codesandbox 链接https://codesandbox.io/s/0xjlvkp9jl

4

0 回答 0