You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
const{ data }=useRequest(reqA)constmap={1: ()=>{useRequest(reqB)},2: ()=>{useRequest(reqC)}}watch(data,(types)=>{types.forEach(type=>map[type]())// !这里超出了setup周期!})
After:
constscope=effectScope()const{ data }=useRequest(reqA)constmap={1: ()=>{useRequest(reqB)},2: ()=>{useRequest(reqC)}}watch(data,(types)=>{scope.run(()=>{types.forEach(type=>map[type]())// ! GOOD !})})onUnmounted(()=>scope.stop())
需求描述 Feature Description
希望能支持EffectScope以获取广泛的使用场景
vue文档
在Vue3中setup是基于EffectScope的,所以这应该是一个非破坏性更新,但是可以扩展很多使用场景
建议的解决方案 Proposed Solution
大概看了一下vue-request的代码,看起来似乎只需要将
onUnmounted
替换为onScopeDispose
即可其他信息 Other information
onScopeDispose看起来是vue3特有的概念,vue2没有,因此vue-demi好像也没有这个方法。为了解决这个问题可以写一个函数:
作为onUnmounted的替代
The text was updated successfully, but these errors were encountered: