<div> <button @click="obtain" v-if="countFind">获取验证码</button> <button disabled v-else="countFind">重新发送({{countdown}})</button> </div>
countdown: 60, countFind: true
obtain () { let that = this this.countFind = false var timer = setInterval(function () { if (that.countdown > 0) { that.countdown-- } else { that.countdown = 0 that.countFind = true that.countdown = 60 clearInterval(timer) } }, 1000) }