Throttle valve allows only one request

 data: {
    // given a status request before whatever data back to allow only one request 0: 1 prior to the request: Request End
    apiOnce: 1,
}
 
methods:{
 // Click to load more data
  MoreData () {
    // blocked by default allows only come in once a request
    if (this.data.apiOnce == 0) {
      return
    }
    // not reset request incoming state 0
    this.setData({
      apiOnce: 0
    })
}
 
}

success: (res) => {
            if (res.data.data.goods_list.length == 0) {
              this.setData ({// success after the successful results to get the state is reset to 1
                apiOnce: 1
              })
            }
          }

Guess you like

Origin www.cnblogs.com/xiaoxiaoxun/p/12134234.html