timeMixin.js 321 B

1234567891011121314151617
  1. export default {
  2. data() {
  3. return {
  4. setTs: []
  5. };
  6. },
  7. methods: {
  8. addSetTime(action, time = 1 * 1000) {
  9. this.setTs.push(setTimeout(action, time));
  10. },
  11. clearSetTs() {
  12. if (!this.setTs.length) return;
  13. this.setTs.forEach(t => clearTimeout(t));
  14. this.setTs = [];
  15. }
  16. }
  17. };