|
1 |
| -# Special Attributes |
| 1 | +# Atributos Especiais |
2 | 2 |
|
3 | 3 | ## key
|
4 | 4 |
|
5 |
| -- **Expects:** `number | string` |
| 5 | +- **Esperado:** `number | string` |
6 | 6 |
|
7 |
| - The `key` special attribute is primarily used as a hint for Vue's virtual DOM algorithm to identify VNodes when diffing the new list of nodes against the old list. Without keys, Vue uses an algorithm that minimizes element movement and tries to patch/reuse elements of the same type in-place as much as possible. With keys, it will reorder elements based on the order change of keys, and elements with keys that are no longer present will always be removed/destroyed. |
| 7 | + O atributo especial `key` é usado principalmente como uma dica para o algoritmo DOM virtual do Vue para identificar VNodes ao comparar a nova lista de nós com a lista antiga. Sem as chaves, o Vue usa um algoritmo que minimiza o movimento do elemento e tenta corrigir/reutilizar elementos do mesmo tipo no local, tanto quanto possível. Com as chaves, ele reordenará os elementos com base na alteração da ordem das chaves, e os elementos com chaves que não estão mais presentes sempre serão removidos/destruídos. |
8 | 8 |
|
9 |
| - Children of the same common parent must have **unique keys**. Duplicate keys will cause render errors. |
| 9 | + Filhos do mesmo pai comum devem ter **chaves únicas**. Chaves duplicadas causarão erros de renderização. |
10 | 10 |
|
11 |
| - The most common use case is combined with `v-for`: |
| 11 | + O caso de uso mais comum é combinado com `v-for`: |
12 | 12 |
|
13 | 13 | ```html
|
14 | 14 | <ul>
|
15 | 15 | <li v-for="item in items" :key="item.id">...</li>
|
16 | 16 | </ul>
|
17 | 17 | ```
|
18 | 18 |
|
19 |
| - It can also be used to force replacement of an element/component instead of reusing it. This can be useful when you want to: |
| 19 | + Também pode ser usado para forçar a substituição de um elemento/componente em vez de reutilizá-lo. Isso pode ser útil quando você deseja: |
20 | 20 |
|
21 |
| - - Properly trigger lifecycle hooks of a component |
22 |
| - - Trigger transitions |
| 21 | + - Acionar corretamente ganchos de ciclo de vida de um componente |
| 22 | + - Transições de gatilho |
23 | 23 |
|
24 |
| - For example: |
| 24 | + Por exemplo: |
25 | 25 |
|
26 | 26 | ```html
|
27 | 27 | <transition>
|
28 | 28 | <span :key="text">{{ text }}</span>
|
29 | 29 | </transition>
|
30 | 30 | ```
|
31 | 31 |
|
32 |
| - When `text` changes, the `<span>` will always be replaced instead of patched, so a transition will be triggered. |
| 32 | + Quando o `texto` muda, o `<span>` sempre será substituído ao invés de corrigido, então uma transição será disparada. |
33 | 33 |
|
34 | 34 | ## ref
|
35 | 35 |
|
36 |
| -- **Expects:** `string | Function` |
| 36 | +- **Esperado:** `string | Function` |
37 | 37 |
|
38 |
| - `ref` is used to register a reference to an element or a child component. The reference will be registered under the parent component's `$refs` object. If used on a plain DOM element, the reference will be that element; if used on a child component, the reference will be component instance: |
| 38 | + `ref` é usado para registrar uma referência a um elemento ou componente filho. A referência será registrada no objeto `$refs` do componente pai. Se usado em um elemento DOM simples, a referência será esse elemento; se usado em um componente filho, a referência será a instância do componente: |
39 | 39 |
|
40 | 40 | ```html
|
41 |
| - <!-- vm.$refs.p will be the DOM node --> |
42 |
| - <p ref="p">hello</p> |
| 41 | + <!-- vm.$refs.p será o nó DOM --> |
| 42 | + <p ref="p">Olá</p> |
43 | 43 |
|
44 |
| - <!-- vm.$refs.child will be the child component instance --> |
| 44 | + <!-- vm.$refs.child será a instância do componente filho --> |
45 | 45 | <child-component ref="child"></child-component>
|
46 | 46 |
|
47 |
| - <!-- When bound dynamically, we can define ref as a callback function, passing the element or component instance explicitly --> |
| 47 | + <!-- Quando vinculado dinamicamente, podemos definir "ref" como uma função de "callback"(retorno de chamada), passando o elemento ou instância do componente explicitamente --> |
48 | 48 | <child-component :ref="(el) => child = el"></child-component>
|
49 | 49 | ```
|
50 | 50 |
|
51 |
| - An important note about the ref registration timing: because the refs themselves are created as a result of the render function, you cannot access them on the initial render - they don't exist yet! `$refs` is also non-reactive, therefore you should not attempt to use it in templates for data-binding. |
| 51 | + Uma observação importante sobre o tempo de registro de uma "ref": como as próprias refs são criadas como resultado da função de renderização, você não pode acessá-los na renderização inicial - eles ainda não existem! `$refs` também não é reativo, portanto, você não deve tentar usá-lo em modelos para vinculação de dados. |
52 | 52 |
|
53 |
| -- **See also:** [Child Component Refs](../guide/component-template-refs.html) |
| 53 | +- **Veja também:** [Refs de Componente Filho](../guide/component-template-refs.html) |
54 | 54 |
|
55 | 55 | ## is
|
56 | 56 |
|
57 |
| -- **Expects:** `string | Object (component’s options object)` |
| 57 | +- **Esperado:** `string | Object (objeto de opções do componente)` |
58 | 58 |
|
59 |
| -Used for [dynamic components](../guide/component-dynamic-async.html). |
| 59 | +Usado para [componentes dinâmicos](../guide/component-dynamic-async.html). |
60 | 60 |
|
61 |
| -For example: |
| 61 | +Por exemplo: |
62 | 62 |
|
63 | 63 | ```html
|
64 |
| -<!-- component changes when currentView changes --> |
| 64 | +<!-- componente muda quando currentView muda --> |
65 | 65 | <component :is="currentView"></component>
|
66 | 66 | ```
|
67 | 67 |
|
68 |
| -- **See also:** |
69 |
| - - [Dynamic Components](../guide/component-dynamic-async.html) |
70 |
| - - [DOM Template Parsing Caveats](../guide/component-basics.html#dom-template-parsing-caveats) |
| 68 | +- **Veja também:** |
| 69 | + - [Componentes Dinâmicos](../guide/component-dynamic-async.html) |
| 70 | + - [Advertências de análise de modelo DOM](../guide/component-basics.html#dom-template-parsing-caveats) |
0 commit comments