<template><div><el-button class="captcha-btn" type="primary" @click="sendSms()">{{ sendContent }}</el-button></div>
</template><script>
export default {data () {return {sendContent: '获取验证码',smsWait: 0,smsSwitch: false}},methods: {// 发送验证码async sendSms () {if (this.smsWait !== 0 || this.smsSwitch) {return false}this.smsSwitch = true// 次处掉接口this.smsSwitch = falsethis.smsWait = 60this.waitSms()this.smsInterval = setInterval(() => {this.waitSms()}, 1000)},waitSms () {this.smsWait--if (this.smsWait === 0) {clearInterval(this.smsInterval)this.sendContent = '重新获取验证码'} else {this.sendContent = this.smsWait + '秒后重新获取'}}}
}
</script><style>
</style>