一. 验证码框
<el-input placeholder="请输入验证码" prefix-icon="el-icon-lock" v-model="ruleForm.code"><el-button slot="suffix" :disabled="disabled" type="text" size="mini" @click="checkbtn"> {{ text }}</el-button>
</el-input>
二.点击事件
data 中声明
text: "获取验证码",
disabled: false,
methods 事件
checkbtn() {this.disabled = truelet sum = 60this.text = sum + 's后在尝试'let setset = setInterval(() => {sum--this.text = sum + 's后在尝试'if (sum == 0){this.disabled = falsethis.text = "获取验证码"clearInterval(set)}}, 1000)
},
是不是很简单!