gpt4 book ai didi

javascript - 当 $watch-es 被 $destroy 时,我需要做些什么来清理它们吗?

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:03:33 25 4
gpt4 key购买 nike

我想避免内存泄漏,所以我想知道当作用域被 $destroy$watches 是否会被自动删除,或者什么应该我要清理吗?

最佳答案

作为$destroy()文档说:

Removal implies that calls to $digest() will no longer propagate to the current scope and its children.

这意味着一旦你的作用域被 $destroyed,你的 $watches 将不再运行,因为它们只能由 $digest 循环处理,当作用域被 $destroyed 时,它被取消。

关于javascript - 当 $watch-es 被 $destroy 时,我需要做些什么来清理它们吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15503179/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com