react-keeper icon indicating copy to clipboard operation
react-keeper copied to clipboard

leaveFilter无法阻止页面跳转?

Open zackchu opened this issue 7 years ago • 3 comments

我在页面中使用CacheLink进行页面的跳转和缓存,但是这里能不能跳转是由每个列表项循环出来的结果单独控制的,所以我希望不能跳转的项可以被leaveFilter阻止掉,但是我在路由配置的地方添加了leaveFilter后并没有达到预期的效果,第一个参数cb不管是否执行,页面都会进行跳转。

<HashRouter>
  <div>
    <Route name='rankitemdetail' path='teacher/detail/:code.html' component={RankItemDetail}/>
    <Route name='rankpage' path='teacher/rankpage.html' component={RankPage}
           leaveFilter={(cb, props) => {
             console.log('不会离开');
             console.log('leave', props);
             cb()
           }}
    />
    <Route cache name='homepage' path=':userType/homepage.html' component={HomePage}/>
  </div>
</HashRouter>

实际不是这么写的,但大体意思是这样。不知道是我配置方法不对还是别的原因?

zackchu avatar Jan 17 '19 09:01 zackchu

@zhshengchao thanks,这是一个待修复问题。需求收集

lanistor avatar Jan 17 '19 14:01 lanistor

@vifird 请问我想在表单验证通过后缓存当前页并跳转到下个页面,但是我在表单逻辑里面控制不了路由里的leaveFilter啊? CacheLlik刚好满足我的需求,但是只能缓存上一个页面,我想缓存所有的上级页面,并在返回上一步的时候,清除所有下级页面的缓存。多级嵌套路由可以做到,但好像有性能问题,我想知道用React-keeper并且不用嵌套路由能做到吗?

andyyxw avatar Apr 05 '19 13:04 andyyxw

@andyyxw cache='parent'可以满足需求吗?

lanistor avatar Apr 08 '19 10:04 lanistor