You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-**NEW:**`key`s are no longer necessary on `v-if`/`v-else`/`v-else-if` branches, since Vue now automatically generates unique `key`s.
11
-
-**BREAKING:**If you manually provide `key`s, then each branch must use a unique `key`. You can no longer intentionally use the same`key`to force branch reuse.
12
-
-**BREAKING:**`<template v-for>``key` should be placed on the `<template>`tag (rather than on its children).
10
+
-**NOVO:**`key`s não são mais necessárias em _branches_`v-if`/`v-else`/`v-else-if`, já que o Vue agora gera automaticamente `key`s únicas.
11
+
-**BREAKING:**Se você informar `key`s manualmente, então cada _branch_ deve ter uma `key` única. Você não pode mais usar intencionalmente a mesma`key`para forçar reuso de _branch_.
12
+
-**BREAKING:**`key`s de `<template v-for>`devem ser colocadas na tag `<template>`(ao invés de em seus filhos).
13
13
14
14
## Background
15
15
16
-
The `key`special attribute is used as a hint for Vue's virtual DOM algorithm to keep track of a node's identity. That way, Vue knows when it can reuse and patch existing nodes and when it needs to reorder or recreate them. For more information, see the following sections:
16
+
O atributo especial `key`é usado como uma dica para o algoritmo de DOM virtual do Vue rastrear a identidade de um nó. Dessa forma, o Vue sabe quando pode reutilizar e corrigir nós existentes e quando precisa reordená-los ou recriá-los. Para mais informações, olhe as seções a seguir:
-[API Reference: `key` Special Attribute](/api/special-attributes.html#key)
18
+
-[Renderização de Listas: Manutenção de Estado](/guide/list.html#manutencao-de-estado)
19
+
-[Referência da API: Atributo Especial `key`](/api/special-attributes.html#key)
20
20
21
-
## On conditional branches
21
+
## Em _Branches_ Condicionais
22
22
23
-
In Vue 2.x, it was recommended to use`key`s on `v-if`/`v-else`/`v-else-if` branches.
23
+
No Vue 2.x, era recomendado o uso de`key`s nos _branches_`v-if`/`v-else`/`v-else-if`.
24
24
25
25
```html
26
26
<!-- Vue 2.x -->
27
-
<divv-if="condition"key="yes">Yes</div>
28
-
<divv-elsekey="no">No</div>
27
+
<divv-if="condition"key="yes">Sim</div>
28
+
<divv-elsekey="no">Não</div>
29
29
```
30
30
31
-
The example above still works in Vue 3.x. However, we no longer recommend using the `key`attribute on`v-if`/`v-else`/`v-else-if` branches, since unique`key`s are now automatically generated on conditional branches if you don't provide them.
31
+
O exemplo acima ainda funciona no Vue 3.x. Porém, não é mais recomendado o uso do atributo `key`em _branches_`v-if`/`v-else`/`v-else-if`, já que`key`s únicas são geradas automaticamente em _branches_ condicionais caso você não as informe.
32
32
33
33
```html
34
34
<!-- Vue 3.x -->
35
-
<divv-if="condition">Yes</div>
36
-
<divv-else>No</div>
35
+
<divv-if="condition">Sim</div>
36
+
<divv-else>Não</div>
37
37
```
38
38
39
-
The breaking change is that if you manually provide `key`s, each branch must use a unique `key`. In most cases, you can remove these`key`s.
39
+
A grande mudança (breaking change) é que se você informar `key`s manualmente, cada branch deverá usar uma `key` única. Na maioria dos casos, você pode remover essas`key`s.
0 commit comments