繁体   English   中英

取消订阅多个 Firestore 快照 VueJS

[英]Unsubscribe multiple firestore snapshots VueJS

在 vuejs 中取消订阅多个快照的正确方法是什么?

I have multiple components, and most of them have a snapshot to take advantage of firebase real time sync, the logout function is located in a navbar component, but once I logout from firebase, I got an error because I'm not unsubscribing from my快照,但是如果它们都在不同的组件上,我该怎么做呢?

有没有办法一次取消订阅所有快照?

提前感谢您的帮助。

要取消订阅快照,您可以使用beforeDestroy 每当您离开此组件时,都会调用它。 在里面,您可以调用从快照中取消订阅的方法。

有关详细信息,请参阅 Vue.js 文档。 https://v2.vuejs.org/v2/api/#beforeDestroy

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM