在下面的代码中:报错说hhFn()不是一个函数这是为啥呢
h5.prototype = {
init:function(){
this.bindEvent();
},
moveFn:function(diff){
for(var i = 0;i<aLi.length;i++){
aLi[i].className = "";
adiv[i].className = "";
}
if(diff<0){
aLi.eq(index+1).className = "selected";
aDiv.eq(index+1).className = "selected";
if(index == 3){
index = -1;
}
}else{
aLi.eq(index-1).className = "selected";
aDiv.eq(index-1).className = "selected";
if(index == 0){
index == 4;
}
}
},
touchStartFn:function(event){
var that = this,
touch = event.touches[0];
startX = touch.pageX;
},
hhFn:function(){
console.log("zzz");
},
touchMoveFn:function(event){
touch = event.touches[0],
x = touch.pageX,
index = this.getAttribute("index"),
diff = x - startX;
this.hhFn();**为啥在这里会说hhFn()不是一个函数**
},
bindEvent:function(){
var that = this;
for(var i = 0;i<aLi.length;i++){
aDiv[i].addEventListener('touchstart', that.touchStartFn, false);
aDiv[i].addEventListener('touchmove', that.touchMoveFn, false);
}
}
};
new h5;`请输入代码`
闭包里面不要用this,var that = this;that.hhFn();