Skip to content

Commit 4a1be34

Browse files
authored
Merge pull request #195 from viniciusarre/101-render-function-api
Traduzir "guide/migration/render-function-api.md"
2 parents f3dcc3f + 095480b commit 4a1be34

File tree

1 file changed

+48
-46
lines changed

1 file changed

+48
-46
lines changed

src/guide/migration/render-function-api.md

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

6-
# Render Function API <MigrationBadges :badges="$frontmatter.badges" />
6+
# API da Função de Renderização <MigrationBadges :badges="$frontmatter.badges" />
77

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

10-
This change will not affect `<template>` users.
10+
Esta mudança não vai afetar usuários de `<template>`.
1111

12-
Here is a quick summary of what has changed:
12+
Aqui está um rápido resumo do que mudou:
1313

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
1717

18-
For more information, read on!
18+
Para mais informações, continue lendo!
1919

20-
## Render Function Argument
20+
## Argumento da Função de Renderização
2121

22-
### 2.x Syntax
22+
### Sintaxe v2.x
2323

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

2626
```js
27-
// Vue 2 Render Function Example
27+
// Exemplo da Função de Renderização no Vue 2
2828
export default {
2929
render(h) {
3030
return h('div')
3131
}
3232
}
3333
```
3434

35-
### 3.x Syntax
35+
### Sintaxe v3.x
3636

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

3939
```js
40-
// Vue 3 Render Function Example
40+
// Exemplo da Função de Renderização no Vue 3
4141
import { h } from 'vue'
4242

4343
export default {
@@ -47,24 +47,24 @@ export default {
4747
}
4848
```
4949

50-
## Render Function Signature Change
50+
## Mudança da Assinatura da Função de Renderização
5151

52-
### 2.x Syntax
52+
### Sintaxe v2.x
5353

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

5656
```js
57-
// Vue 2 Render Function Example
57+
// Exemplo da Função Render no Vue 2
5858
export default {
5959
render(h) {
6060
return h('div')
6161
}
6262
}
6363
```
6464

65-
### 3.x Syntax
65+
### Sintaxe v3.x
6666

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()`.
6868

6969
```js
7070
import { h, reactive } from 'vue'
@@ -79,7 +79,7 @@ export default {
7979
state.count++
8080
}
8181

82-
// return the render function
82+
// retorna a função de renderização
8383
return () =>
8484
h(
8585
'div',
@@ -92,16 +92,16 @@ export default {
9292
}
9393
```
9494

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).
9696

97-
## VNode Props Format
97+
## Formato de Props VNode
9898

99-
### 2.x Syntax
99+
### Sintaxe v2.x
100100

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

103103
```js
104-
// 2.x
104+
// v2.x
105105
{
106106
staticClass: 'button',
107107
class: {'is-outlined': isOutlined },
@@ -114,12 +114,12 @@ In 2.x, `domProps` contained a nested list within the VNode props:
114114
}
115115
```
116116

117-
### 3.x Syntax
117+
### Sintaxe v3.x
118118

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

121121
```js
122-
// 3.x Syntax
122+
// Sintaxe v3.x
123123
{
124124
class: ['button', { 'is-outlined': isOutlined }],
125125
style: [{ color: '#34495E' }, { backgroundColor: buttonColor }],
@@ -130,11 +130,11 @@ In 3.x, the entire VNode props structure is flattened. Using the example from ab
130130
}
131131
```
132132

133-
## Registered Component
133+
## Componente Registrado
134134

135-
### 2.x Syntax
135+
### Sintaxe v2.x
136136

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

139139
```js
140140
// 2.x
@@ -146,7 +146,7 @@ Vue.component('button-counter', {
146146
}
147147
template: `
148148
<button @click="count++">
149-
Clicked {{ count }} times.
149+
Clicado {{ count }} vezes.
150150
</button>
151151
`
152152
})
@@ -158,12 +158,12 @@ export default {
158158
}
159159
```
160160

161-
### 3.x Syntax
161+
### Sintaxe v3.x
162162

163-
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`:
164164

165165
```js
166-
// 3.x
166+
// v3.x
167167
import { h, resolveComponent } from 'vue'
168168

169169
export default {
@@ -174,18 +174,20 @@ export default {
174174
}
175175
```
176176

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

179-
## Migration Strategy
181+
## Estratégia de Migração
180182

181-
### Library Authors
183+
### Autores de Biblioteca
182184

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

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
188190

189-
## Next Steps
191+
## Próximos Passos
190192

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

Comments
 (0)