Skip to content

Commit ed9ac70

Browse files
committed
Fix english at guide/render-function
1 parent e58631d commit ed9ac70

File tree

1 file changed

+49
-49
lines changed

1 file changed

+49
-49
lines changed

src/guide/render-function.md

+49-49
Original file line numberDiff line numberDiff line change
@@ -246,17 +246,17 @@ render() {
246246
}
247247
```
248248

249-
## Creating Component VNodes
249+
## Criando VNodes de Componentes
250250

251-
To create a VNode for a component, the first argument passed to `h` should be the component itself:
251+
Para criar um VNode para um componente, o primeiro argumento passado para `h` deve ser o próprio componente:
252252

253253
```js
254254
render() {
255255
return h(ButtonCounter)
256256
}
257257
```
258258

259-
If we need to resolve a component by name then we can call `resolveComponent`:
259+
Se precisarmos resolver um componente pelo nome, podemos chamar `resolveComponent`:
260260

261261
```js
262262
const { h, resolveComponent } = Vue
@@ -269,12 +269,12 @@ render() {
269269
}
270270
```
271271

272-
`resolveComponent` is the same function that templates use internally to resolve components by name.
272+
`resolveComponent` é a mesma função que os _templates_ usam internamente para resolver componentes por nome.
273273

274-
A `render` function will normally only need to use `resolveComponent` for components that are [registered globally](/guide/component-registration.html#global-registration). [Local component registration](/guide/component-registration.html#local-registration) can usually be skipped altogether. Consider the following example:
274+
Uma função `render` normalmente só precisa usar `resolveComponent` para componentes que são [registrados globalmente](/guide/component-registration.html#registro-global). Assim o [registro local de componentes](/guide/component-registration.html#registro-local) geralmente pode ser ignorado por completo. Considere o seguinte exemplo:
275275

276276
```js
277-
// We can simplify this
277+
// Podemos simplificar isso
278278
components: {
279279
ButtonCounter
280280
},
@@ -283,7 +283,7 @@ render() {
283283
}
284284
```
285285

286-
Rather than registering a component by name and then looking it up we can use it directly instead:
286+
Em vez de registrar um componente pelo nome e depois procurá-lo, podemos usá-lo diretamente:
287287

288288
```js
289289
render() {
@@ -319,7 +319,7 @@ render() {
319319
}
320320
```
321321

322-
In a template it can be useful to use a `<template>` tag to hold a `v-if` or `v-for` directive. When migrating to a `render` function, the `<template>` tag is no longer required and can be discarded.
322+
Em um _template_ pode ser útil usar uma tag `<template>` para conter uma diretiva `v-if` ou `v-for`. Ao migrar para uma função `render`, a tag `<template>` não é mais necessária e pode ser descartada.
323323

324324
### `v-model`
325325

@@ -437,23 +437,23 @@ render() {
437437
}
438438
```
439439

440-
The slots are passed as functions, allowing the child component to control the creation of each slot's contents. Any reactive data should be accessed within the slot function to ensure that it's registered as a dependency of the child component and not the parent. Conversely, calls to `resolveComponent` should be made outside the slot function, otherwise they'll resolve relative to the wrong component:
440+
Os slots são passados ​​como funções, permitindo que o componente filho controle a criação do conteúdo de cada slot. Quaisquer dados reativos devem ser acessados ​​dentro da função do slot para garantir que sejam registrados como uma dependência do componente filho e não do pai. Por outro lado, chamadas ao `resolveComponent` devem ser feitas fora da função do slot, caso contrário, elas serão resolvidas em relação ao componente errado:
441441

442442
```js
443443
// `<MyButton><MyIcon :name="icon" />{{ text }}</MyButton>`
444444
render() {
445-
// Calls to resolveComponent should be outside the slot function
445+
// Chamadas para resolveComponent devem estar fora da função slot
446446
const Button = resolveComponent('MyButton')
447447
const Icon = resolveComponent('MyIcon')
448448

449449
return h(
450450
Button,
451451
null,
452452
{
453-
// Use an arrow function to preserve the `this` value
453+
// Use uma arrow function para preservar o valor de `this`
454454
default: (props) => {
455-
// Reactive properties should be read inside the slot function
456-
// so that they become dependencies of the child's rendering
455+
// Propriedades reativas devem ser lidas dentro da função slot
456+
// para que se tornem dependências da renderização do filho
457457
return [
458458
h(Icon, { name: this.icon }),
459459
this.text
@@ -464,40 +464,40 @@ render() {
464464
}
465465
```
466466

467-
If a component receives slots from its parent, they can be passed on directly to a child component:
467+
Se um componente recebe slots de seu pai, eles podem ser passados ​​diretamente para um componente filho:
468468

469469
```js
470470
render() {
471471
return h(Panel, null, this.$slots)
472472
}
473473
```
474474

475-
They can also be passed individually or wrapped as appropriate:
475+
Eles também podem ser passados ​​individualmente ou envolvidos conforme apropriado:
476476

477477
```js
478478
render() {
479479
return h(
480480
Panel,
481481
null,
482482
{
483-
// If we want to pass on a slot function we can
483+
// Se quisermos passar uma função de slot podemos
484484
header: this.$slots.header,
485485

486-
// If we need to manipulate the slot in some way
487-
// then we need to wrap it in a new function
486+
// Se precisarmos manipular o slot de alguma forma
487+
// então precisamos envolvê-lo em uma nova função
488488
default: (props) => {
489489
const children = this.$slots.default ? this.$slots.default(props) : []
490490

491-
return children.concat(h('div', 'Extra child'))
491+
return children.concat(h('div', 'Filho extra'))
492492
}
493493
}
494494
)
495495
}
496496
```
497497

498-
### `<component>` and `is`
498+
### `<component>` e `is`
499499

500-
Behind the scenes, templates use `resolveDynamicComponent` to implement the `is` attribute. We can use the same function if we need all the flexibility provided by `is` in our `render` function:
500+
Nos bastidores, os _templates_ usam `resolveDynamicComponent` para implementar o atributo `is`. Podemos usar a mesma função se precisarmos de toda a flexibilidade fornecida por `is` em nossa função `render`:
501501

502502
```js
503503
const { h, resolveDynamicComponent } = Vue
@@ -511,13 +511,13 @@ render() {
511511
}
512512
```
513513

514-
Just like `is`, `resolveDynamicComponent` supports passing a component name, an HTML element name, or a component options object.
514+
Assim como `is`, `resolveDynamicComponent` suporta a passagem de um nome de componente, um nome de elemento HTML ou um objeto de opções de componente.
515515

516-
However, that level of flexibility is usually not required. It's often possible to replace `resolveDynamicComponent` with a more direct alternative.
516+
No entanto, esse nível de flexibilidade geralmente não é necessário. Muitas vezes é possível substituir `resolveDynamicComponent` por uma alternativa mais direta.
517517

518-
For example, if we only need to support component names then `resolveComponent` can be used instead.
518+
Por exemplo, se precisarmos apenas oferecer suporte a nomes de componentes, então `resolveComponent` pode ser usado.
519519

520-
If the VNode is always an HTML element then we can pass its name directly to `h`:
520+
Se o VNode for sempre um elemento HTML, podemos passar seu nome diretamente para `h`:
521521

522522
```js
523523
// `<component :is="bold ? 'strong' : 'em'"></component>`
@@ -526,13 +526,13 @@ render() {
526526
}
527527
```
528528

529-
Similarly, if the value passed to `is` is a component options object then there's no need to resolve anything, it can be passed directly as the first argument of `h`.
529+
Da mesma forma, se o valor passado para `is` for um objeto de opções de componente, então não há necessidade de resolver nada, ele pode ser passado diretamente como o primeiro argumento de `h`.
530530

531-
Much like a `<template>` tag, a `<component>` tag is only required in templates as a syntactical placeholder and should be discarded when migrating to a `render` function.
531+
Assim como uma tag `<template>`, uma tag `<component>` só é necessária em _templates_ como um espaço reservado sintático e deve ser descartada ao migrar para uma função `render`.
532532

533-
### Custom Directives
533+
### Diretivas Personalizadas
534534

535-
Custom directives can be applied to a VNode using [`withDirectives`](/api/global-api.html#withdirectives):
535+
Diretivas personalizadas podem ser aplicadas a um VNode usando [`withDirectives`](/api/global-api.html#withdirectives):
536536

537537
```js
538538
const { h, resolveDirective, withDirectives } = Vue
@@ -549,13 +549,13 @@ render () {
549549
}
550550
```
551551

552-
[`resolveDirective`](/api/global-api.html#resolvedirective) is the same function that templates use internally to resolve directives by name. That is only necessary if you don't already have direct access to the directive's definition object.
552+
[`resolveDirective`](/api/global-api.html#resolvedirective) é a mesma função que os _templates_ usam internamente para resolver diretivas por nome. Isso só é necessário se você ainda não tiver acesso direto ao objeto de definição da diretiva.
553553

554-
### Built-in Components
554+
### Componentes Integrados
555555

556-
[Built-in components](/api/built-in-components.html) such as `<keep-alive>`, `<transition>`, `<transition-group>`, and `<teleport>` are not registered globally by default. This allows bundlers to perform tree-shaking, so that the components are only included in the build if they are used. However, that also means we can't access them using `resolveComponent` or `resolveDynamicComponent`.
556+
[Componentes integrados](/api/built-in-components.html), como `<keep-alive>`, `<transition>`, `<transition-group>` e `<teleport>` por padrão não são registrados globalmente. Isso permite que empacotadores executem o _tree-shaking_ para que os componentes sejam incluídos na compilação apenas se forem usados. No entanto, isso também significa que não podemos acessá-los usando `resolveComponent` ou `resolveDynamicComponent`.
557557

558-
Templates have special handling for those components, automatically importing them when they are used. When we're writing our own `render` functions, we need to import them ourselves:
558+
_Templates_ possuem tratamento especial para esses componentes, importando-os automaticamente quando utilizados. Quando estamos escrevendo nossas próprias funções `render`, precisamos importá-las nós mesmos:
559559

560560
```js
561561
const { h, KeepAlive, Teleport, Transition, TransitionGroup } = Vue
@@ -567,32 +567,32 @@ render () {
567567
}
568568
```
569569

570-
## Return Values for Render Functions
570+
## Valores de Retorno para Funções de Renderização
571571

572-
In all of the examples we've seen so far, the `render` function has returned a single root VNode. However, there are alternatives.
572+
Em todos os exemplos que vimos até agora, a função `render` retornou um único VNode raiz. No entanto, existem alternativas.
573573

574-
Returning a string will create a text VNode, without any wrapping element:
574+
Retornar uma string criará um VNode de texto, sem nenhum elemento de encapsulamento:
575575

576576
```js
577577
render() {
578-
return 'Hello world!'
578+
return 'Olá mundo!'
579579
}
580580
```
581581

582-
We can also return an array of children, without wrapping them in a root node. This creates a fragment:
582+
Também podemos retornar um array de filhos, sem envolvê-los em um nó raiz. Isso cria um fragmento:
583583

584584
```js
585-
// Equivalent to a template of `Hello<br>world!`
585+
// Equivalente a um template de `Olá<br>mundo!`
586586
render() {
587587
return [
588-
'Hello',
588+
'Olá',
589589
h('br'),
590-
'world!'
590+
'mundo!'
591591
]
592592
}
593593
```
594594

595-
If a component needs to render nothing, perhaps because data is still loading, it can just return `null`. This will be rendered as a comment node in the DOM.
595+
Se um componente não precisar renderizar nada, talvez porque os dados ainda estão sendo carregados, ele pode simplesmente retornar `null`. Isso será renderizado como um nó de comentário no DOM.
596596

597597
## JSX
598598

@@ -636,30 +636,30 @@ app.mount('#demo')
636636

637637
Para saber mais sobre como JSX mapeia para o JavaScript, veja a [documentação de uso](https://github.com/vuejs/jsx-next#installation).
638638

639-
## Functional Components
639+
## Componentes Funcionais
640640

641-
Functional components are an alternative form of component that don't have any state of their own. They are rendered without creating a component instance, bypassing the usual component lifecycle.
641+
Componentes funcionais são uma forma alternativa de componente que não possui nenhum estado próprio. Eles são renderizados sem criar uma instância de componente, ignorando o ciclo de vida normal do componente.
642642

643-
To create a functional component we use a plain function, rather than an options object. The function is effectively the `render` function for the component. As there is no `this` reference for a functional component, Vue will pass in the `props` as the first argument:
643+
Para criar um componente funcional, usamos uma função simples, em vez de um objeto de opções. A função é efetivamente a função `render` para o componente. Como não há referência de `this` para um componente funcional, o Vue passará o `props` como primeiro argumento:
644644

645645
```js
646646
const FunctionalComponent = (props, context) => {
647647
// ...
648648
}
649649
```
650650

651-
The second argument, `context`, contains three properties: `attrs`, `emit`, and `slots`. These are equivalent to the instance properties [`$attrs`](/api/instance-properties.html#attrs), [`$emit`](/api/instance-methods.html#emit), and [`$slots`](/api/instance-properties.html#slots) respectively.
651+
O segundo argumento, `context`, contém três propriedades: `attrs`, `emit` e `slots`. Elas são equivalentes às propriedades de instância [`$attrs`](/api/instance-properties.html#attrs), [`$emit`](/api/instance-methods.html#emit) e [`$slots`](/api/instance-properties.html#slots) respectivamente.
652652

653-
Most of the usual configuration options for components are not available for functional components. However, it is possible to define [`props`](/api/options-data.html#props) and [`emits`](/api/options-data.html#emits) by adding them as properties:
653+
A maioria das opções de configuração usuais para componentes não está disponível para componentes funcionais. No entanto, é possível definir [`props`](/api/options-data.html#props) e [`emits`](/api/options-data.html#emits) adicionando-os como propriedades:
654654

655655
```js
656656
FunctionalComponent.props = ['value']
657657
FunctionalComponent.emits = ['click']
658658
```
659659

660-
If the `props` option is not specified, then the `props` object passed to the function will contain all attributes, the same as `attrs`. The prop names will not be normalized to camelCase unless the `props` option is specified.
660+
Se a opção `props` não for especificada, então o objeto `props` passado para a função conterá todos os atributos, o mesmo que `attrs`. Os nomes das props não serão normalizados para camelCase a menos que a opção `props` seja especificada.
661661

662-
Functional components can be registered and consumed just like normal components. If you pass a function as the first argument to `h`, it will be treated as a functional component.
662+
Componentes funcionais podem ser registrados e consumidos como componentes normais. Se você passar uma função como primeiro argumento para `h`, ela será tratada como um componente funcional.
663663

664664
## Compilação de _Template_
665665

0 commit comments

Comments
 (0)