接口2需要接口1返回的数据才能调用的情况,使用监控

几个要点

  • 监听的数据是reactive对象里的属性,所以需要deep监听,否则监听不到
  • 第一个接口如果调用多次,这里也会调用多次,可能会有问题
watch(
    () => state.editData.gateShops, 
    (New, Old) => {
      console.log('---------------',New,'--------------',Old);
      productPreSaleService.save({
        saleType: 65,
        ...state.editData,
        itemDetonation: state.editData.imageInfo[0].url || null,

      }).then(res => {
        console.log('runnnnningggg',res);
        closeModal({
          refresh: true,
          payload: {

          }
        })
      })
    }, 
    { deep: true })

}
posted @ 2024-07-30 10:59  ayubene  阅读(3)  评论(0编辑  收藏  举报