Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
下面的图片可能会更好地解释它。我在树视图中有一个父节点列表,我检查每个节点以确保它们具有子节点。如果他们这样做,那么我会在 for 循环中遍历每个子节点,但即使 i = 0 它告诉我它超出了范围,即使你可以看到它们存在。
它们实际上是不存在的。 注意正上方childCount: 0。
childCount: 0
您在私有数组中看到的是预先分配的空间来容纳任何未来的孩子。