下是一段获取元素位置,并通过判断index值,使其向左或向右运动的代码局部。在运行过程中报错,this._setPara is not a funtion...百思不得其解,请各位指教~多谢~
_setPara : function(){
this._b = this.swContainer.css("left");
this._move();
},
moveLeft : function(){
this._setPara();
this.index++;
if(this.index == this.swCounter){
setTimeout(this.moveRight, this.swDuration);
}else{
setTimeout(this.moveLeft, this.swDuration);
}
},
moveRight : function(){
this._setPara();
this.index--;
if(this.index == 0){
setTimeout(this.moveLeft, this.swDuration);
}else{
setTimeout(this.moveRight, this.swDuration);
}
},Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
放入setTimeout内部的函数,this会指向window,而不再是原对象。
解决方法: var _self = this;