0
Follow
0
View

Bootstrap5 Carousel with await promise

diotzhou 注册会员
2023-01-25 19:36

I have sorted it out. I had to initiate a new carousel and run cycle method. See the code:

 function delay() {
      return new Promise((resolve, reject) => {
        setTimeout(resolve,1000);
      });
  }
  async function start() {
    await delay();
    insertCarousel();
    let myCarousel = document.querySelector('#carouselExampleIndicators');
    let carousel = new bootstrap.Carousel(myCarousel, {
      interval: 3000
      }).cycle();
  }
 
start();

About the Author

Question Info

Publish Time
2023-01-25 19:36
Update Time
2023-01-25 19:36