antd 防止多次查询

<a-button type="primary" 
		:loading="loading" 
		@click="findCarrier" >{{$t('Query')}}
a-button>

methods

setTime(){
    //每隔一段时间运行一次清除方法
    this.timer = setInterval(()=>{
      this.clearRequestNum();
    },5000)
},
created() {
  	this.setTime();
},
beforeDestroy(){
    clearInterval(this.timer);
},

store.js

state:{
	firstQuery:0,
    loading:false,
    requestNum:0,
},
mutations:{
	clearRequestNum(state){
	    state.loading = false;
	    state.requestNum = 0;
	},
}

if(++state.requestNum >= 2 && state.firstQuery > 0){
     state.loading = true;
     return;
}

你可能感兴趣的:(javascript,开发语言,ecmascript)