我有以下代码,我试图在滑动事件中调用,方法this.swipe触发任何函数。问题是它不知道this.cwipe在上下文this.carousel.swipe中是什么。我该如何触发此功能?
PM.SwipeCarousel = function (carouselSelector) {
this.carousel = $j(carouselSelector);
this.carousel.swipe({
swipe : this.swipe
})
// method to call
this.swipe = function(event, direction, distance, duration, fingerCount, fingerData) {
console.log(event, direction, distance, duration, fingerCount, fingerData);
}
}
答案 0 :(得分:0)
建议的代码应该是
PM.SwipeCarousel = function (carouselSelector) {
this.carousel = $j(carouselSelector);
// method to call
this.swipe = function(event, direction, distance, duration, fingerCount, fingerData) {
console.log(event, direction, distance, duration, fingerCount, fingerData);
}
this.carousel.swipe({
swipe : this.swipe
})
}