猿问

call是js自带的函数???? javascript 回调函数

var timer = setInterval(function(){

         var t = new Date() - startTime;

         var d = time;

         if ( t >= d )

         {

                 t = d;

                 clearInterval( timer );

                 callback();

         }

//callback()放于此处会导致少执行一次for循环

         for ( var key in mJson )

         {

                 var b = startVal[key];

                 var c = endVal[key] - b;

                 var s = Tween[cv]( t , b , c , d );

                 obj.style[key] = s + 'px';

         }

},13);


/////改写为

var timer = setInterval(function(){

         var t = new Date() - startTime;

         var d = time;

         if ( t >= d )

         {

                 t = d;

                 clearInterval( timer );

         }

         for ( var key in mJson )

         {

                 var b = startVal[key];

                 var c = endVal[key] - b;

                 var s = Tween[cv]( t , b , c , d );

                 obj.style[key] = s + 'px';

         }

         if ( t == d )

         {

                  callback && callback.call(obj);

         }

},13);

//callback是自命名的函数可换为wangdachui



qq_唔叫咩_0
浏览 883回答 1
1回答

慕设计6931647

是的。 call是js自带的函数哦。
随时随地看视频慕课网APP

相关分类

JavaScript
我要回答