
router-view 的组件 A 和 B 共用一个组件 C,C 组件有个插槽,A 在 C 中插入了 D 组件。
经过测试,在 AB 组件中切换时,C 组件会执行 beforeDestroy 钩子,但 A 和 B 和 D 组件的钩子函数都不会重新执行。
如何不然 C 组件销毁? 谢谢!
1 yinggcy OP 试了下给 C 组件加 keep-alive,beforeDestroy 不会被触发,但是在 AB 组件间切换还会触发 created,mounted 等钩子 |
2 GressJoe 2021 年 5 月 13 日 activated,deactivated? |
3 yinggcy OP @GressJoe 不是, 按道理说 created,mounted 等钩子函数整个生命周期应该只能触发一次, 但是因为 keep-alive 失效导致多次触发了 |