javascript - Owl-Carousel2 - 设置点数据

标签 javascript jquery owl-carousel owl-carousel-2

我需要在 Owl Carousel 中设置自定义点。我在 JS 中有这段代码:

$(document).ready(function() {
  $('#header-slider').owlCarousel({
    loop: true,
    autoplay: true,
    autoplayTimeout: 2300,
    pagination: false,
    navigation: true,
    navText: [$('.am-next'), $('.am-prev')],
    navigation: true,
    margin: 0,
    dotsData: ["<button role='button' class='owl-dot'></button><svg version='1.1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' x='0px' y='0px' width='16' height='16' viewbox='0 0 250 250' enable-background='new 0 0 426.667 410' xml:space='preserve'><path class='loader' transform='translate(125, 125) scale(.84)'></svg>"],
    responsive: {
      0: {
        items: 1
      },
      600: {
        items: 1
      },
      1000: {
        items: 1,
        nav: false
      },
      1200: {
        items: 1,
        nav: false
      }
    }
  });
});

但是这段代码没有任何反应,只是显示了未定义的点。甚至可以制作这样的自定义点吗?

最佳答案

将下面的代码改成这样:

$(document).ready(function() {
  $('#header-slider').owlCarousel({
    loop: true,
    autoplay: true,
    autoplayTimeout: 2300,
    pagination: false,
    navigation: true,
    navText: [$('.am-next'), $('.am-prev')],
    navigation: true,
    margin: 0,
    dotData: true,
    dotsData: true
    responsive: {
      0: {
        items: 1
      },
      600: {
        items: 1
      },
      1000: {
        items: 1,
        nav: false
      },
      1200: {
        items: 1,
        nav: false
      }
    }
  });
});

在你的猫头鹰项目中添加你的点数据:

  <div class="item" data-dot="<button role='button' class='owl-dot'></button>">
     <!-- Your Image -->
  </div>

关于javascript - Owl-Carousel2 - 设置点数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53336303/

相关文章:

jquery - 如何在中心显示 Owl Carousel 导航?

javascript - Google Analytics API 的 jQuery AJAX header 身份验证

javascript - 为什么我的变量在函数内部修改后没有改变? - 异步代码引用

javascript - XMLHttpRequest responseText在不同浏览器中的结果不同

javascript - 为什么 JavaScript 中的数学方法比按位运算符更快?

javascript - JQuery 选择器找不到通过追加添加的对象

javascript - 即使在 jQuery 中删除类名,也会触发 Click 事件

javascript - 在 Backbone View 中填充 React 组件

javascript - 在 Vue.js 中进行 AJAX 调用后重新加载轮播

css - Angular CLI 7.1.3 如何改变 Owl Carousel 点的颜色?