javascript - OWL 轮播在自动播放中添加 #slide-0/1/2

标签 javascript owl-carousel

我已经为我的一个项目实现了 Owl carousal。 当页面加载完成并自动播放轮播时。它在我的 URL 中添加了#slide。

Eg.
www.example.com/home#slide-0  
www.example.com/home#slide-1  
www.example.com/home#slide-2

是否有任何我需要禁用的设置。

最佳答案

您已将 URLhashListener 设置为 true,您必须将其从 owl carousel 设置对象中删除,或将其设置为 false。 https://owlcarousel2.github.io/OwlCarousel2/demos/urlhashnav.html

这是打开自动播放的 Owl Carousel 。

$('.owl-carousel').owlCarousel({
    loop:true,
    margin:10,
    nav:true,
	autoplay: true,
	autoplayTimeout:1000,
	autoplayHoverPause:true,
    responsive:{
        0:{
            items:1
        },
        600:{
            items:3
        },
        1000:{
            items:5
        }
    }
})
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>Owl Carousel</title>
</head>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.2.1/assets/owl.carousel.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.2.1/assets/owl.theme.default.css">	
<body>
<div class="owl-carousel owl-theme">
    <div class="item"><h4>1</h4></div>
    <div class="item"><h4>2</h4></div>
    <div class="item"><h4>3</h4></div>
    <div class="item"><h4>4</h4></div>
    <div class="item"><h4>5</h4></div>
    <div class="item"><h4>6</h4></div>
    <div class="item"><h4>7</h4></div>
    <div class="item"><h4>8</h4></div>
    <div class="item"><h4>9</h4></div>
    <div class="item"><h4>10</h4></div>
    <div class="item"><h4>11</h4></div>
    <div class="item"><h4>12</h4></div>
</div>
<script src="https://code.jquery.com/jquery-3.1.0.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.2.1/owl.carousel.js"></script>	
</body>
</html>

关于javascript - OWL 轮播在自动播放中添加 #slide-0/1/2,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42620372/

相关文章:

javascript - 即使使用 javascript 且没有框架更改 html 页面,也可以使视频连续播放

用于在问号之前获取字符串的 Javascript 正则表达式(如果存在)

javascript - 如何正确删除 React 状态数组中的元素?

javascript - 是否可以为 React Treebeard 单独处理点击事件和切换

jquery - Owl Carousel 显示后的停用延迟加载

javascript - Owl Carousel 中堆叠的图像

javascript - Owl Carousel 更改不起作用

javascript - Material UI - 如何在页面折叠时交换网格元素的左/右垂直位置

javascript - 在事件元素周围添加额外空间

jquery - Owl Carousel ,显示子绝对div,超过父溢出隐藏div