Skip to content

vue会自动给vnode添加key吗? #341

@wisonxiang

Description

@wisonxiang

vue渲染器在更新列表时,会触发diff算法,diff算法依赖vnode上的key做算法优化。但在写模版时,除了v-for渲染列表会手写key。其他情况并不会去手写key,如:

<div id="parent">
    <h1 id="child">1</h1>
    <h1 id="child">2</h1>
    <h1 id="child">3</h1>
</div>
···
更新时也会触发diff算法?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions