<template> <el-input size="small" placeholder="请输入验证码" v-model="phoneCode"> <el-button :disabled="disSend" size="small" slot="append" @click="send">{{BtnName}}</el-button> </el-input> </template> <script> export default { data() { return { phoneCode: '', BtnName: '发送验证码', disSend:false } }, methods: { send() { this.disSend = true this.$alert('已向手机号13908056224发送短信', '温馨提示', { confirmButtonText: '确定', callback: action => { let count = 60; let timer = null if (!timer) { timer = setInterval(() => { if (count > 1) { count--; this.BtnName = count + '秒后重发' } else { clearInterval(timer); timer = null; this.disSend = false this.BtnName = '发送验证码' } }, 1000) } } }); } } } </script>