Javascript 猫头鹰转盘2-如何获取当前项目?

Javascript 猫头鹰转盘2-如何获取当前项目?,javascript,jquery,owl-carousel,Javascript,Jquery,Owl Carousel,我在一个有猫头鹰转盘2的网站上工作。 我只想检测哪个项目显示在前面 过去是这样的。 但这是版本1的一个例子。 在第二版中,上述内容不起作用,根据官方文件,我们似乎应该使用“信息”。 我试图弄明白,但没有额外的例子或文档。我也检查了.js文件,但没有找到它。我想知道“信息”是否还没有实现 我真的不想知道信息,只是想得到当前项目的数据 我在下面也尝试过这种方法,但它不能正常工作。 你有什么可能的解决办法吗 var active = $("#owl-demo").find(".owl-item.a

我在一个有猫头鹰转盘2的网站上工作。 我只想检测哪个项目显示在前面

过去是这样的。

但这是版本1的一个例子。 在第二版中,上述内容不起作用,根据官方文件,我们似乎应该使用“信息”。

我试图弄明白,但没有额外的例子或文档。我也检查了.js文件,但没有找到它。我想知道“信息”是否还没有实现

我真的不想知道信息,只是想得到当前项目的数据

我在下面也尝试过这种方法,但它不能正常工作。 你有什么可能的解决办法吗

var active = $("#owl-demo").find(".owl-item.active");
console.log(active.text());

我不能不回答就离开这里。 你是这样做的。我在文档中也找不到它。我深入研究了源代码

owl.on('changed.owl.carousel', function (e) {
    console.log("current: ",e.relatedTarget.current())
    console.log("current: ",e.item.index) //same
    console.log("total: ",e.item.count)   //total
})
更多信息:如果希望此事件触发初始状态。您应该在初始化owl之前添加它们。像这样

var owl = $("#yourItem")
owl.on('changed.owl.carousel', function (e) {
    console.log("current: ",e.relatedTarget.current())
    console.log("current: ",e.item.index) //same
    console.log("total: ",e.item.count)   //total
})
// then init
owl.owlCarousel({settings})

使用版本1。Verison 2是有缺陷的,文档是违反直觉的。显然,mainteiner已经不在乎了。有500多个悬而未决的问题。版本2不仅很糟糕。它也阻止了版本1。非常感谢!我使用了一系列if语句来检测页面(如下)触发器“changed.owl.carousel”似乎是正确的做法:)谢谢!由于反向拖动不能正常工作,请您help@Gopalarajanaika举个例子问你的问题,然后标记我,我不是占星家。这是什么语法?!你好,安娜·维瓦斯。虽然您的代码很棒,但如果您可以为其添加一些上下文,例如代码的每个部分都做了什么,这样每个人都可以理解代码,而不仅仅是复制粘贴,那就更好了。祝您有个美好的一天!
var owl = $("#yourItem")
owl.on('changed.owl.carousel', function (e) {
    console.log("current: ",e.relatedTarget.current())
    console.log("current: ",e.item.index) //same
    console.log("total: ",e.item.count)   //total
})
// then init
owl.owlCarousel({settings})
owl.on('changed.owl.carousel', function (e) {
    //console.log("current: ",e.item.index) //same
    if (("current: ",e.item.index == 0)){
        console.log("page01");
    } 
    if (("current: ",e.item.index == 1)){
        console.log("page02");
    }                  
})
var owl = $("#yourItem")
owl.on('changed.owl.carousel', function (e) {
    $('.current').text(e.relatedTarget.relative(e.relatedTarget.current()) + 1);
    $('.allitems').text(e.item.count);
})
// then init
owl.owlCarousel({settings})