Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

keep-alive activated and deactivated hooks should trigger recursively when toggled #4242

Closed
nothinggift opened this issue Nov 18, 2016 · 12 comments

Comments

@nothinggift
Copy link

No description provided.

@yyx990803
Copy link
Member

yyx990803 commented Nov 18, 2016

Please be more specific on why you think it should work like that, and what use case are you running into that needs this. A single title doesn't qualify as a feature request.

@nothinggift
Copy link
Author

很抱歉没有做更详细的说明,我们项目中的页面级组件都会带有设置页面meta属性的参数,当页面跳转时会自动设置这些属性,很自然他们是由activated/created来触发的,而在部分嵌套页面里,这个功能失效了,于是我们发现了这个问题。
keep-alive的组件在重新激活时,不会触发子组件的任何事件钩子,这导致在需要刷新子组件时,只能由父组件手动去触发,如果是多级嵌套的组件就会非常繁琐,所以希望keep-alive支持更细粒度的操作。
子组件随父组件activated/deactivated,他们理应触发这些钩子啊。

@tgustinak
Copy link

tgustinak commented Nov 24, 2016

I have the same issue. Activated/Deactivated are called only on the components registered by router. So children of these components cannot benefit from activated/deactivated lifecycle hooks.

Do you think this will be in next releases?

@kinglion
Copy link

kinglion commented Nov 25, 2016

同样的困惑,假如A跟B两个组件都有keep-alive。他们有共同的组件C,那么A初始化的时候C会执行一次create,B初始化的时候C同样会执行一次create。这时返回A,页面上的C组件不会触发任何生命周期的事件...假如C有个prop,A跟B都有传递,用watch监听这个prop也不会触发事件

@nothinggift
Copy link
Author

@kinglion keep-alive的子组件目前不触发生命周期事件钩子,需要手动调用,调用方法参考callHook 方法

@kinglion
Copy link

@nothinggift 嗯,这个也是一个hack方法 😊

@zuibunan
Copy link

zuibunan commented Dec 7, 2016

keep-alive的子组件目前不触发生命周期事件钩子,需要手动调用,调用方法参考callHook 方法

这个就太麻烦的,我的页面现在全都是keep-alive的,每个页面根元素是个自己封装的组件,里面加了一些回调,比如动画结束之类的回调事件,如果需要手动去触发子组件的钩子,每个页面都得在activated函数里callHook,这个应该能在每个组件中配置是否触发子组件的钩子

@kinsliy
Copy link

kinsliy commented Dec 11, 2016

我也遇到这个问题,谁有解决办法??请告诉我,thank you

@aierui
Copy link

aierui commented Dec 11, 2016

you can remove it.

@huanghuixin1
Copy link

@aierui How to remove it?

@yyx990803 yyx990803 changed the title keep-alive的组件应同样触发子组件的activated与deactivated钩子 keep-alive activated and deactivated hooks should trigger recursively when toggled Jan 22, 2017
@cqgsm
Copy link

cqgsm commented Aug 25, 2017

我的第三级路由组件 ,只能触发deactivated函数, activated不能触发,很奇怪啊,二级路由就都可以触发,下面是子路由插座的写法

<transition name="slide">
            <keep-alive>
                <router-view class="child-view"></router-view>
            </keep-alive>
</transition>

@zydemail
Copy link

也遇到同样的问题,路由对应的入口组件里边的activated,deactivated钩子触发了,但是入口组件里边引用的子组件的deactivated,activated钩子都没有被触发

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests