FlipClock.js on event 不是函数

FlipClock.js on event is not a function

当我尝试使用 on 方法获取事件时,FlipClock.js 出错。

我的代码:

var counter = $('.counter').FlipClock(0, {
    clockFace: 'Counter',
    minimumDigits: 3
}).on('set:time', function() {
    alert('test');
});

我在控制台上有这个:

Uncaught TypeError: $(...).FlipClock(...).on is not a function

通过查看您的 jsfiddle 示例,我发现您没有对 jQuery 元素做出反应。

我已经通过以下更改测试了您的代码:

$(document).ready(function () {

  var counter = $('.counter').FlipClock(0, {
    clockFace: 'Counter',
    minimumDigits: 3,
    events: true
  });
  counter.$el.on('set:time', function() {
    alert('test event');
  });

  $(document).on('click', 'button', function () {
    alert('Set!');
    counter.setTime(10);
  });
});

这非常有效!

在我的更正中,我正在通过 jQuery 元素监听事件。

请投票并批准答案。