Skip to content

Commit 51c236f

Browse files
authored
Merge pull request #185 from LucasBremm/master
Docs: Translation of guide/migration/key-attribute.md to Portuguese
2 parents 6d4406d + be6e514 commit 51c236f

File tree

1 file changed

+28
-28
lines changed

1 file changed

+28
-28
lines changed

src/guide/migration/key-attribute.md

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3,58 +3,58 @@ badges:
33
- breaking
44
---
55

6-
# `key` attribute <MigrationBadges :badges="$frontmatter.badges" />
6+
# Atributo `key` <MigrationBadges :badges="$frontmatter.badges" />
77

8-
## Overview
8+
## Visão Geral
99

10-
- **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).
1313

1414
## Background
1515

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:
1717

18-
- [List Rendering: Maintaining State](/guide/list.html#maintaining-state)
19-
- [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)
2020

21-
## On conditional branches
21+
## Em _Branches_ Condicionais
2222

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`.
2424

2525
```html
2626
<!-- Vue 2.x -->
27-
<div v-if="condition" key="yes">Yes</div>
28-
<div v-else key="no">No</div>
27+
<div v-if="condition" key="yes">Sim</div>
28+
<div v-else key="no">Não</div>
2929
```
3030

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.
3232

3333
```html
3434
<!-- Vue 3.x -->
35-
<div v-if="condition">Yes</div>
36-
<div v-else>No</div>
35+
<div v-if="condition">Sim</div>
36+
<div v-else>Não</div>
3737
```
3838

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.
4040

4141
```html
4242
<!-- Vue 2.x -->
43-
<div v-if="condition" key="a">Yes</div>
44-
<div v-else key="a">No</div>
43+
<div v-if="condition" key="a">Sim</div>
44+
<div v-else key="a">Não</div>
4545

46-
<!-- Vue 3.x (recommended solution: remove keys) -->
47-
<div v-if="condition">Yes</div>
48-
<div v-else>No</div>
46+
<!-- Vue 3.x (solução recomendada: remover as keys) -->
47+
<div v-if="condition">Sim</div>
48+
<div v-else>Não</div>
4949

50-
<!-- Vue 3.x (alternate solution: make sure the keys are always unique) -->
51-
<div v-if="condition" key="a">Yes</div>
52-
<div v-else key="b">No</div>
50+
<!-- Vue 3.x (solução alternativa: garantir que as keys sejam sempre únicas) -->
51+
<div v-if="condition" key="a">Sim</div>
52+
<div v-else key="b">Não</div>
5353
```
5454

55-
## With `<template v-for>`
55+
## Com `<template v-for>`
5656

57-
In Vue 2.x, a `<template>` tag could not have a `key`. Instead, you could place the `key`s on each of its children.
57+
No Vue 2.x, uma tag `<template>` não poderia ter uma `key`. Em vez disso, você poderia colocar as `key`s em cada uma de suas tags filhas.
5858

5959
```html
6060
<!-- Vue 2.x -->
@@ -64,7 +64,7 @@ In Vue 2.x, a `<template>` tag could not have a `key`. Instead, you could place
6464
</template>
6565
```
6666

67-
In Vue 3.x, the `key` should be placed on the `<template>` tag instead.
67+
No Vue 3.x, a `key` deve ser colocada na tag `<template>`.
6868

6969
```html
7070
<!-- Vue 3.x -->
@@ -74,7 +74,7 @@ In Vue 3.x, the `key` should be placed on the `<template>` tag instead.
7474
</template>
7575
```
7676

77-
Similarly, when using `<template v-for>` with a child that uses `v-if`, the `key` should be moved up to the `<template>` tag.
77+
Similarmente, quando houver uma tag `<template v-for>` com uma tag filha que use `v-if`, a `key` deve ser movida para a tag `<template>`.
7878

7979
```html
8080
<!-- Vue 2.x -->

0 commit comments

Comments
 (0)