正如杰克所说,使用“on”而不是“live”作为绑定方法。您可能需要考虑检测设备是否支持触摸并将其用作绑定的基础。某些设备会同时触发 click 和 touchstart ,从而导致不可预知的效果。
/* Touch event support */
utils.POINTER_EVENT = (function() {
//check if the browser supports touch events
var supportsTouch = 'createTouch' in document;
//base our event names on the result...
var obj = {
START: (supportsTouch) ? 'touchstart' : 'mousedown',
MOVE: (supportsTouch) ? 'touchmove' : 'mousemove',
END: (supportsTouch) ? 'touchend' : 'mouseup',
getPointerPosition: function(ev) { return { x: (supportsTouch) ? ev.touches[0].pageX : ev.pageX, y: (supportsTouch) ? ev.touches[0].pageY : ev.pageY }; }
};
return obj;
})();
然后绑定到 utils.POINTER_EVENT