vant防止重复提交-loading

本文详细介绍了在Vant Vue组件库中如何有效地防止用户在提交表单时进行重复点击,确保数据的正确性和一致性。通过利用Vant的loading组件结合Promise,实现提交按钮的锁定,避免多次请求,提升用户体验。
-----
<van-button type="primary" block @click="commit" :loading="loading" 
loading-type="spinner" >提交审核</van-button>
---
 commit() {                     //提交数据
        this.loading=true    //显示加载转圈圈
        axios.post('https://simbajs.com:7002/subject/add',{
            section_id:1,
            title:this.title,
            answer:this.answer,
            section_name:this.type,
            desc:this.message

        })
        .then(res => {
            console.log(res)
            if (res.data.success) {        //数据加载成功 圈圈false
                this.loading=false
                this.title=''
                this.type=''
                this.answer=''
                this.message=''
            }

        })
        // setTimeout(() => {
        //     this.loading=false
        // }, 2000);
       
        },
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值