javascript的promise.all方法使用以及解构等

javascript的promise.all方法使用以及解构等   001

//定义$ref(接收数据)
let statusData = $ref({
    /** 设备状态统计数量 */
    total: 0,
    /** 设备正常数量 */
    normalTotal: 0,
    /** 设备故障数量 */
    faultTotal: 0,
    /** 设备维护数量 */
    maintenanceTotal: 0,
    /** 设备停用数量 */
    stopTotal: 0,
    pointTotal: 0
  })
//在计算属性里写
 const data = computed(() => {
    // 默认顺序
    const DEFAULT: LinkItem[] = [
      {
        title: '点位数',
        num: statusData.pointTotal
      },
      {
        title: '总设备数',
        num: statusData.total
      },
      {
        title: '正常设备数',
        num: statusData.normalTotal,
        status: 'yes'
      },
      {
        title: '故障设备数',
        num: statusData.faultTotal,
        status: 'error'
      },
      {
        title: '维护中设备数',
        num: statusData.maintenanceTotal,
        status: 'Disable'
      },
      {
        title: '停用设备数',
        num: statusData.stopTotal,
        status: 'Close'
      }
    ]
    return { ...DEFAULT }
  })

javascript的promise.all方法使用以及解构等   002

 try {
      const [res1, res2] = await Promise.all([
        getVisualizationCount(),
        getPointPage({
          limit: 0,
          id: '',
          tenantId: '',
          organizationId: '',
          name: '',
          ids: [],
          number: ''
        })
      ])

      statusData = { ...res1, pointTotal: res2.totalCount }
      console.log(statusData)
    } catch (err: any) {
      message.error(err.message)
    }

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值