我的JS应用程序中有以下代码,但它不起作用,我也没有在调试应用程序中看到任何错误。
你能告诉我我失踪的是什么吗?谢谢!
function mouseActivity(e)
{
if(e=='mousedown' || e=='touchstart') {
mouseDown = true;
var coords = calcCoordinates(couponCanvas, e);
drawEventPath();
return false;
}
if(e=='mousemove' || e=='touchmove'){
if (!mouseDown)
return true;
var coords = calcCoordinates(couponCanvas, e);
return false;
}
if(e=='mouseup' || e=='touchend'){
if (mouseDown)
{
mouseDown = false;
return false;
}
return true;
}
}
上述功能将决定对不同的鼠标/触摸事件采取的操作。它是从另一个函数调用的:
function dummy(){
couponCanvas.addEventListener('mousedown', mouseActivity);
couponCanvas.addEventListener('touchstart', mouseActivity);
window.addEventListener('mousemove', mouseActivity);
window.addEventListener('touchmove', mouseActivity);
window.addEventListener('mouseup', mouseActivity);
window.addEventListener('touchend', mouseActivity);
}
答案 0 :(得分:2)
您在活动中缺少类型,请检查类型
event.type;