美文网首页
vue里节流和防抖写法

vue里节流和防抖写法

作者: 随风飞2019 | 来源:发表于2020-08-13 09:31 被阅读0次

    防抖debounce

    getTableData: _.debounce(async function () {
          let params = {
            pageIndex: this.currentPage,
            pageSize: this.pageSize,
            selectType: this.activeTabName
          }
          let res = await getIeoApplyList(params)
          this.total = Number(res.data.total)
          this.list = res.data.list
        }, 500),
    
    传参的方式
    getDetailById: _.debounce(async function (id) {
          let params = {id: id}
          let res = await getIeoApplyDetail(params)
          this.detailInfo = res.data
        }, 500),
    

    节流throttle

    doPurchase: _.throttle(async function () {
          const params = {
            id: this.id,
            rushNum: this.buyCount,
            payPassword: this.$globalPayPassword_S_X
          }
    
          this.list = await doPurchaseAJAX(params)
        }, 500),
    

    相关文章

      网友评论

          本文标题:vue里节流和防抖写法

          本文链接:https://www.haomeiwen.com/subject/ppxbdktx.html