Showing
2 changed files
with
3 additions
and
2 deletions
| ... | @@ -223,7 +223,7 @@ export function getTime(type) { | ... | @@ -223,7 +223,7 @@ export function getTime(type) { |
| 223 | * @return {*} | 223 | * @return {*} |
| 224 | */ | 224 | */ |
| 225 | export function debounce(func, wait, immediate) { | 225 | export function debounce(func, wait, immediate) { |
| 226 | - let timeout, args, context, timestamp, result; | 226 | + let timeout, args, context, timestamp, result, data; |
| 227 | 227 | ||
| 228 | const later = function () { | 228 | const later = function () { |
| 229 | // 据上一次触发时间间隔 | 229 | // 据上一次触发时间间隔 |
| ... | @@ -236,7 +236,7 @@ export function debounce(func, wait, immediate) { | ... | @@ -236,7 +236,7 @@ export function debounce(func, wait, immediate) { |
| 236 | timeout = null; | 236 | timeout = null; |
| 237 | // 如果设定为immediate===true,因为开始边界已经调用过了此处无需调用 | 237 | // 如果设定为immediate===true,因为开始边界已经调用过了此处无需调用 |
| 238 | if (!immediate) { | 238 | if (!immediate) { |
| 239 | - result = func.apply(context, args); | 239 | + result = func.apply(context, data); |
| 240 | if (!timeout) context = args = null; | 240 | if (!timeout) context = args = null; |
| 241 | } | 241 | } |
| 242 | } | 242 | } |
| ... | @@ -245,6 +245,7 @@ export function debounce(func, wait, immediate) { | ... | @@ -245,6 +245,7 @@ export function debounce(func, wait, immediate) { |
| 245 | return function (...args) { | 245 | return function (...args) { |
| 246 | context = this; | 246 | context = this; |
| 247 | timestamp = +new Date(); | 247 | timestamp = +new Date(); |
| 248 | + data = args; | ||
| 248 | const callNow = immediate && !timeout; | 249 | const callNow = immediate && !timeout; |
| 249 | // 如果延时不存在,重新设定延时 | 250 | // 如果延时不存在,重新设定延时 |
| 250 | if (!timeout) timeout = setTimeout(later, wait); | 251 | if (!timeout) timeout = setTimeout(later, wait); | ... | ... |
src/utils/mixins.js
deleted
100644 → 0
This diff is collapsed. Click to expand it.
-
Please register or login to post a comment