From 0f20a032b124d346aede94f4b0ab8bb4d3b0c90f Mon Sep 17 00:00:00 2001 From: Tidusww <305574626@qq.com> Date: Tue, 27 Nov 2018 17:49:41 +0800 Subject: [PATCH] Update directive.js MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit lastExec应该使用Date.now(),如果使用now变量,lastExec在大多数情况下会比预期要小,造成目标函数的执行间隔偶尔会小于设定的间隔 --- src/directive.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/directive.js b/src/directive.js index fefbed0..982113f 100644 --- a/src/directive.js +++ b/src/directive.js @@ -4,8 +4,8 @@ var throttle = function (fn, delay) { var now, lastExec, timer, context, args; //eslint-disable-line var execute = function () { + lastExec = Date.now(); fn.apply(context, args); - lastExec = now; }; return function () {