SendVerifyCode.js 607 B

1234567891011121314151617181920212223242526272829
  1. export default {
  2. data() {
  3. return {
  4. disabled: false,
  5. text: this.$t('验证码')
  6. };
  7. },
  8. methods: {
  9. sendCode() {
  10. if (this.disabled) return;
  11. this.disabled = true;
  12. let n = 60;
  13. this.text = this.$t('剩余') + n + "s";
  14. const run = setInterval(() => {
  15. n = n - 1;
  16. if (n < 0) {
  17. clearInterval(run);
  18. }
  19. this.text = this.$t('剩余') + n + "s";
  20. if (this.text < this.$t('剩余') + 0 + "s") {
  21. this.disabled = false;
  22. this.text = this.$t('重新获取');
  23. }
  24. }, 1000);
  25. }
  26. }
  27. };