vue button 多次点击重复提交

//发表评论
sendComment () {
this.disabled = true
if (this.text == ''){
this.$message({
type:'error',
message:'输入内容不能为空',
})
this.disabled = false
}else{
this.$post('/xx/xx/IdleGoodsComment',{
goods_id:this.$route.params.id,
content:this.text,
user_id:window.uId,
type:1
}).then((res) => {
if(res){
this.getDetail()
setTimeout(()=>{
this.disabled=false
this.getCommentList()
this.text = ''}
,2000)
this.disabled = true
}
})
}
}
实现原理:通过计时器讲button属性更改,点击完之后讲button属性设置为disable
vue绑定button的disable属性为:disabled:'变量名'

posted @ 2018-05-02 11:04  -http  阅读(3043)  评论(0编辑  收藏  举报