检测滑动滑块何时初始化 [英] Detect when slick slider initialises
本文介绍了检测滑动滑块何时初始化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
slick 初始化时,我正在尝试触发一些代码.显然,在最新的1.4版中,不建议使用回调方法,并用事件代替."
I'm trying to fire some code when slick initializes. Apparently in the newest version 1.4 "callback methods have been deprecated and replaced with events."
这对我来说不起作用:
$('.spv-slider').on('init', function(event, slick){
console.log("initialised")
});
这是怎么了?
推荐答案
我不确定您在何时尝试初始化slickslider,但必须在 绑定init
之后执行事件.
I'm not sure at which point you tried to initialize slickslider, but you have to do it after binding the init
event.
因此,请像以前一样编写代码,然后初始化滑块:
So write your piece of code as you did and after that initialize the slider:
$('.spv-slider').on('init', function(event, slick){
console.log("initialized")
});
然后:
$('.spv-slider').slick();
这篇关于检测滑动滑块何时初始化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文