amis icon indicating copy to clipboard operation
amis copied to clipboard

与 React 开发时,有办法获取 CRUD 组件的数据吗?

Open 17 opened this issue 6 years ago • 2 comments

实现场景:

使用了 CRUD 自动刷新功能,当后台有新订单时,需要筛选符合要求的订单,播放提示音提醒用户。

存在的问题:

需要获取 CRUD 组件的数据,判断订单是否符合要求,现在使用 Axios 的拦截器判断 URL 获取数据,十分不优雅。 有更好的方法吗?

17 avatar Nov 19 '20 22:11 17

做过的尝试:

  useEffect(()=>{
    console.log(scoped)
    const intervalID = setInterval(()=>{
      console.log(scoped.getComponents()) // result []
      console.log(scoped.getComponentByName('attendant_order.attendant_order_crud')) // result null
    }, 1000)
    return () => clearInterval(intervalID)
  })

但是没能获取 Components 。

17 avatar Nov 20 '20 08:11 17

可以直接在接口上写适配器,然后写你的逻辑

RickCole21 avatar Dec 25 '20 09:12 RickCole21