template
<el-button :plain="true" @click="openMessage">错误</el-button>
script
export default {
data() {
return {
timer: null
}
},
methods: {
clearTimout() {
clearTimeout(this.timer)
this.timer = null
},
openMessage() {
if(!this.timer){
this.$message.error('错了哦,这是一条错误消息');
this.timer = setTimeout(()=>{
this.clearTimout()
}, 3000)
}
}
}
}
网友评论