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
Copy file name to clipboardExpand all lines: src/guide/migration/render-function-api.md
+48-46Lines changed: 48 additions & 46 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,41 +3,41 @@ badges:
3
3
- breaking
4
4
---
5
5
6
-
# Render Function API <MigrationBadges:badges="$frontmatter.badges" />
6
+
# API da Função de Renderização <MigrationBadges:badges="$frontmatter.badges" />
7
7
8
-
## Overview
8
+
## Visão Geral
9
9
10
-
This change will not affect `<template>` users.
10
+
Esta mudança não vai afetar usuários de `<template>`.
11
11
12
-
Here is a quick summary of what has changed:
12
+
Aqui está um rápido resumo do que mudou:
13
13
14
-
-`h`is now globally imported instead of passed to render functions as an arguments
15
-
-render function arguments changed to be more consistent between stateful and functional components
16
-
- VNodes now have a flat props structure
14
+
-`h`agora é globalmente importado em vez de passado como argumento para funções de renderização
15
+
-Argumentos da função de renderização mudaram para serem mais consistentes entre componentes funcionais e com estado
16
+
- VNodes agora têm uma estrutura plana de props
17
17
18
-
For more information, read on!
18
+
Para mais informações, continue lendo!
19
19
20
-
## Render Function Argument
20
+
## Argumento da Função de Renderização
21
21
22
-
### 2.x Syntax
22
+
### Sintaxe v2.x
23
23
24
-
In 2.x, the `render`function would automatically receive the `h`function (which is a conventional alias for `createElement`) as an argument:
24
+
Na v2.x, a função `render`receberia automaticamente a função `h`(que é um _alias_ para `createElement`) como argumento:
25
25
26
26
```js
27
-
//Vue 2 Render Function Example
27
+
//Exemplo da Função de Renderização no Vue 2
28
28
exportdefault {
29
29
render(h) {
30
30
returnh('div')
31
31
}
32
32
}
33
33
```
34
34
35
-
### 3.x Syntax
35
+
### Sintaxe v3.x
36
36
37
-
In 3.x, `h`is now globally imported instead of being automatically passed as an argument.
37
+
Na v3.x, o `h`agora é importado globalmente em vez de automaticamente passado como um argumento.
38
38
39
39
```js
40
-
//Vue 3 Render Function Example
40
+
//Exemplo da Função de Renderização no Vue 3
41
41
import { h } from'vue'
42
42
43
43
exportdefault {
@@ -47,24 +47,24 @@ export default {
47
47
}
48
48
```
49
49
50
-
## Render Function Signature Change
50
+
## Mudança da Assinatura da Função de Renderização
51
51
52
-
### 2.x Syntax
52
+
### Sintaxe v2.x
53
53
54
-
In 2.x, the `render`function automatically received arguments such as`h`.
54
+
Na v2.x, a função `render`recebeu automaticamente argumentos como o`h`.
55
55
56
56
```js
57
-
//Vue 2 Render Function Example
57
+
//Exemplo da Função Render no Vue 2
58
58
exportdefault {
59
59
render(h) {
60
60
returnh('div')
61
61
}
62
62
}
63
63
```
64
64
65
-
### 3.x Syntax
65
+
### Sintaxe v3.x
66
66
67
-
In 3.x, since the `render`function no longer receives any arguments, it will primarily be used inside of the `setup()` function. This has the added benefit of gaining access to reactive state and functions declared in scope, as well as the arguments passed to`setup()`.
67
+
Na v3.x, desde que a função `render`já não recebe argumentos, ela será primeiramente usada dentro da função `setup()`. Isso traz o benefício adicional em ganhar acesso ao estado reativo e às funções declaradas no escopo, assim como argumentos passados para o`setup()`.
68
68
69
69
```js
70
70
import { h, reactive } from'vue'
@@ -79,7 +79,7 @@ export default {
79
79
state.count++
80
80
}
81
81
82
-
//return the render function
82
+
//retorna a função de renderização
83
83
return () =>
84
84
h(
85
85
'div',
@@ -92,16 +92,16 @@ export default {
92
92
}
93
93
```
94
94
95
-
For more information on how `setup()`works, see our [Composition API Guide](/guide/composition-api-introduction.html).
95
+
Para mais informações em como o `setup()`funciona, veja nosso [Guia da API de Composição](/guide/composition-api-introduction.html).
96
96
97
-
## VNode Props Format
97
+
## Formato de Props VNode
98
98
99
-
### 2.x Syntax
99
+
### Sintaxe v2.x
100
100
101
-
In 2.x, `domProps`contained a nested list within the VNode props:
101
+
Na v2.x, o `domProps`continha uma lista aninhada dentro dos props VNode:
102
102
103
103
```js
104
-
//2.x
104
+
//v2.x
105
105
{
106
106
staticClass:'button',
107
107
class: {'is-outlined': isOutlined },
@@ -114,12 +114,12 @@ In 2.x, `domProps` contained a nested list within the VNode props:
114
114
}
115
115
```
116
116
117
-
### 3.x Syntax
117
+
### Sintaxe v3.x
118
118
119
-
In 3.x, the entire VNode props structure is flattened. Using the example from above, here is what it would look like now.
119
+
Na v3.x, toda a estrutura de props do VNode é achatada. Usando o exemplo acima, agora ele ficaria algo assim.
@@ -130,11 +130,11 @@ In 3.x, the entire VNode props structure is flattened. Using the example from ab
130
130
}
131
131
```
132
132
133
-
## Registered Component
133
+
## Componente Registrado
134
134
135
-
### 2.x Syntax
135
+
### Sintaxe v2.x
136
136
137
-
In 2.x, when a component has been registered, the render function would work well when passing the component's name as a string to the first argument:
137
+
Na v2.x, quando um componente é registrado, a função de renderização funcionaria bem quando passado o nome do componente como uma string para o primeiro argumento:
In 3.x, with VNodes being context-free, we can no longer use a string ID to implicitly lookup registered components. Instead, we need to use an imported `resolveComponent` method:
163
+
Na v3.x, com os VNodes sendo livres de contexto, não podemos usar um ID como string para implicitamente buscar por componentes registrados. Em vez disso, precisamos usar o método importado `resolveComponent`:
164
164
165
165
```js
166
-
//3.x
166
+
//v3.x
167
167
import { h, resolveComponent } from'vue'
168
168
169
169
exportdefault {
@@ -174,18 +174,20 @@ export default {
174
174
}
175
175
```
176
176
177
-
For more information, see [The Render Function Api Change RFC](https://github.com/vuejs/rfcs/blob/master/active-rfcs/0008-render-function-api-change.md#context-free-vnodes).
177
+
Para mais informações, veja [O RFC* das mudanças da API da Função de Renderização](https://github.com/vuejs/rfcs/blob/master/active-rfcs/0008-render-function-api-change.md#context-free-vnodes).
178
+
179
+
***Nota da tradução**: RFC significa _Request For Comments_ (Solicitação de Comentários), e é um processo que visa prover um caminho consistente e controlado para as novas funcionalidades de um framework.
178
180
179
-
## Migration Strategy
181
+
## Estratégia de Migração
180
182
181
-
### Library Authors
183
+
### Autores de Biblioteca
182
184
183
-
`h`being globally imported means that any library that contains Vue components will include `import { h } from 'vue'`somewhere. As a result, this creates a bit of overhead since it requires library authors to properly configure the externalization of Vue in their build setup:
185
+
A importação global do `h`significa que qualquer biblioteca que contenha componentes Vue vão incluir `import { h } from 'vue'`em algum lugar. Como resultado, isso cria um pouco de sobrecarga, pois requer que os autores de biblioteca configurem corretamente a externalização do Vue em suas configurações de compilação:
184
186
185
-
- Vue should not be bundled into the library
186
-
-For module builds, the import should be left alone and be handled by the end user bundler
187
-
-For UMD / browser builds, it should try the global Vue.h first and fallback to require calls
187
+
-o Vue não deve estar empacotado na biblioteca
188
+
-Para construções de módulo, a importação deve ser deixada sozinha e tratada pelo empacotador do usuário final
189
+
-Para UMD / compilações de navegador, deve-se tentar o Vue.h global primeiro e alternar para exigir chamadas se necessário
188
190
189
-
## Next Steps
191
+
## Próximos Passos
190
192
191
-
See [Render Function Guide](/guide/render-function)for more detailed documentation!
193
+
Veja [O Guia da Função de Renderização](/guide/render-function)para documentação mais detalhada!
0 commit comments