debounce.js 342 B

12345678910111213141516171819202122
  1. export default {
  2. a: {},
  3. canDoFunction(e = {}) {
  4. if (!this.a[e.key]) {
  5. this.lockKey(e.key);
  6. e.success && e.success();
  7. if (e.time) {
  8. setTimeout(() => {
  9. this.releaseKey(e.key)
  10. }, e.time)
  11. }
  12. } else {
  13. e.fail && e.fail()
  14. }
  15. },
  16. releaseKey(key) {
  17. delete this.a[key]
  18. },
  19. lockKey(key) {
  20. this.a[key] = true
  21. }
  22. }