js请求后端前端代码会不会阻塞呢(等待后端返回数据后再往下执行)

getList() {
        this.listLoading = true

        this.getDepartmentTree()

        sysApi.getPageList(this.listQuery).then(response => {
          debugger
          let records = response.data.records
          this.list = [] 
          // 此法效率比较低
          for (let record of records) {
            if(record.createBy == this.$store.state.user.userName && record.delFlag == 0){
              console.log(this.treeSelectData)
              debugger
              for (let key in this.treeSelectData) {
                if(this.treeSelectData[key].id == record.makerId ){
                  record.makerId = this.treeSelectData[key].name
                }
              }
              this.list.push(record)
            }
          }
          this.total = this.list.length
          this.listLoading = false
        });
        this.$forceUpdate()
      },

说明:
this.getDepartmentTree()会向后端发起请求。
发起请求后,并不一定保证后端已经返回数据的情况下,前端会立即执行sysApi.getPageList及以下代码。
而不是阻塞,等待后端返回数据再去执行sysApi.getPageList

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

建筑转Java-张无忌

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值