Skip to content

Commit 54876fe

Browse files
committed
docs: Translate file component-dynamic-async
1 parent 4d21a52 commit 54876fe

File tree

1 file changed

+29
-29
lines changed

1 file changed

+29
-29
lines changed

src/guide/component-dynamic-async.md

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,51 @@
1-
# Dynamic & Async Components
1+
# Componentes Dinâmicos e Assíncronos
22

3-
> This page assumes you've already read the [Components Basics](component-basics.md). Read that first if you are new to components.
3+
> Essa página pressupõe que você já leu [Componentes Básicos](component-basics.md). Leia isso primeiro se você for novo em componentes.
44
5-
## Dynamic Components with `keep-alive`
5+
## Componentes dinâmicos com `keep-alive`
66

7-
Earlier, we used the `is` attribute to switch between components in a tabbed interface:
7+
Anteriormente, usamos o atributo `is` para alternar entre os componentes em uma _interface_ com guias:
88

99
```vue-html
1010
<component :is="currentTabComponent"></component>
1111
```
1212

13-
When switching between these components though, you'll sometimes want to maintain their state or avoid re-rendering for performance reasons. For example, when expanding our tabbed interface a little:
13+
Todavia, ao alternar entre esses componentes, às vezes você desejará manter seu estado ou evitar uma nova renderização por motivos de desempenho. Por exemplo, vamos expandir um pouco nossa _interface_ com guias:
1414

1515
<p class="codepen" data-height="300" data-theme-id="39028" data-default-tab="html,result" data-user="Vue" data-slug-hash="jOPjZOe" data-editable="true" style="height: 300px; box-sizing: border-box; display: flex; align-items: center; justify-content: center; border: 2px solid; margin: 1em 0; padding: 1em;" data-pen-title="Dynamic components: without keep-alive">
16-
<span>See the Pen <a href="https://codepen.io/team/Vue/pen/jOPjZOe">
17-
Dynamic components: without keep-alive</a> by Vue (<a href="https://codepen.io/Vue">@Vue</a>)
18-
on <a href="https://codepen.io">CodePen</a>.</span>
16+
<span>Veja o Pen <a href="https://codepen.io/team/Vue/pen/jOPjZOe">
17+
Componentes Dinâmicos: sem keep-alive</a> por Vue (<a href="https://codepen.io/Vue">@Vue</a>)
18+
no <a href="https://codepen.io">CodePen</a>.</span>
1919
</p>
2020
<script async src="https://static.codepen.io/assets/embed/ei.js"></script>
2121

22-
You'll notice that if you select a post, switch to the _Archive_ tab, then switch back to _Posts_, it's no longer showing the post you selected. That's because each time you switch to a new tab, Vue creates a new instance of the `currentTabComponent`.
22+
Você notará que, se selecionar uma postagem, alternar para a guia _Arquivo_ e, em seguida, voltar para _Postagens_, ela não estará mais mostrando a postagem que você selecionou. Isso porque, a cada vez que você muda para uma nova guia, o Vue cria uma instância do `currentTabComponent`.
2323

24-
Recreating dynamic components is normally useful behavior, but in this case, we'd really like those tab component instances to be cached once they're created for the first time. To solve this problem, we can wrap our dynamic component with a `<keep-alive>` element:
24+
Recriar componentes dinâmicos normalmente é um comportamento útil, mas neste caso, realmente gostaríamos que essas instâncias do componente de guia fossem armazenadas em _cache_ assim que fosserm criadas pela primeira vez. Para resolver esse problema, podemos envolver nosso componente dinâmico com um elemento `<keep-alive>`:
2525

2626
```vue-html
27-
<!-- Inactive components will be cached! -->
27+
<!-- Os componentes inativos serão armazenados em cache! -->
2828
<keep-alive>
2929
<component :is="currentTabComponent"></component>
3030
</keep-alive>
3131
```
3232

33-
Check out the result below:
33+
Confira o resultado abaixo:
3434

3535
<p class="codepen" data-height="300" data-theme-id="39028" data-default-tab="html,result" data-user="Vue" data-slug-hash="VwLJQvP" data-editable="true" style="height: 300px; box-sizing: border-box; display: flex; align-items: center; justify-content: center; border: 2px solid; margin: 1em 0; padding: 1em;" data-pen-title="Dynamic components: with keep-alive">
36-
<span>See the Pen <a href="https://codepen.io/team/Vue/pen/VwLJQvP">
37-
Dynamic components: with keep-alive</a> by Vue (<a href="https://codepen.io/Vue">@Vue</a>)
38-
on <a href="https://codepen.io">CodePen</a>.</span>
36+
<span>Veja o Pen <a href="https://codepen.io/team/Vue/pen/VwLJQvP">
37+
Componentes Dinâmicos: com keep-alive</a> por Vue (<a href="https://codepen.io/Vue">@Vue</a>)
38+
no <a href="https://codepen.io">CodePen</a>.</span>
3939
</p>
4040
<script async src="https://static.codepen.io/assets/embed/ei.js"></script>
4141

42-
Now the _Posts_ tab maintains its state (the selected post) even when it's not rendered.
42+
Agora a guia _Postagens_ mantém seu estado (a postagem selecionada) mesmo quando não é renderizada.
4343

44-
Check out more details on `<keep-alive>` in the [API reference](../api/built-in-components.html#keep-alive).
44+
Confira mais detalhes sobre `<keep-alive>` na [Referência da API](../api/built-in-components.html#keep-alive).
4545

46-
## Async Components
46+
## Componentes Assíncronos
4747

48-
In large applications, we may need to divide the app into smaller chunks and only load a component from the server when it's needed. To make that possible, Vue has a `defineAsyncComponent` method:
48+
Em grandes aplicações, podemos precisar dividir o aplicativo em pedaços menores e carregar um componente do servidor apenas quando for necessário. Para tornar isso possível, o Vue tem o método `defineAsyncComponent`:
4949

5050
```js
5151
const app = Vue.createApp({})
@@ -54,17 +54,17 @@ const AsyncComp = Vue.defineAsyncComponent(
5454
() =>
5555
new Promise((resolve, reject) => {
5656
resolve({
57-
template: '<div>I am async!</div>'
57+
template: '<div>Eu sou assíncrono!</div>',
5858
})
5959
})
6060
)
6161

6262
app.component('async-example', AsyncComp)
6363
```
6464

65-
As you can see, this method accepts a factory function returning a `Promise`. Promise's `resolve` callback should be called when you have retrieved your component definition from the server. You can also call `reject(reason)` to indicate the load has failed.
65+
Como você pode ver, esse método aceita uma função de fábrica(_factory function_) que retorna uma `Promise`. O _callback_ `resolve` da Promise deve ser chamado quando você recupera a definição do componente do servidor. Você também pode chamar o `reject(motivo)` para indicar que o carregamento falhou.
6666

67-
You can also return a `Promise` in the factory function, so with Webpack 2 or later and ES2015 syntax you can do:
67+
Você também pode retornar uma `Promise` na _factory function_, com o Webpack 2 ou posterior e a sintaxe ES2015, você pode fazer:
6868

6969
```js
7070
import { defineAsyncComponent } from 'vue'
@@ -76,7 +76,7 @@ const AsyncComp = defineAsyncComponent(() =>
7676
app.component('async-component', AsyncComp)
7777
```
7878

79-
You can also use `defineAsyncComponent` when [registering a component locally](component-registration.html#local-registration):
79+
Você também pode usar o `defineAsyncComponent` ao [registrar um componente localmente](component-registration.html#local-registration):
8080

8181
```js
8282
import { createApp, defineAsyncComponent } from 'vue'
@@ -86,15 +86,15 @@ createApp({
8686
components: {
8787
AsyncComponent: defineAsyncComponent(() =>
8888
import('./components/AsyncComponent.vue')
89-
)
90-
}
89+
),
90+
},
9191
})
9292
```
9393

94-
### Using with Suspense
94+
### Usando com Suspense
9595

96-
Async components are _suspensible_ by default. This means if it has a [`<Suspense>`](TODO) in the parent chain, it will be treated as an async dependency of that `<Suspense>`. In this case, the loading state will be controlled by the `<Suspense>`, and the component's own loading, error, delay and timeout options will be ignored.
96+
Os componentes assíncronos são _suspensos_ por padrão. Isso significa que, se houver um [`<Suspense>`](TODO) na cadeia (pai), ele será tratado como uma dependência assíncrona desse `<Suspense>`. Nesse caso, o estado de carregamento vai se controlado pelo `<Suspense>`, e as opções de carregamento, erro, atraso e tempo limite do próprio componente serão ignoradas.
9797

98-
The async component can opt-out of `Suspense` control and let the component always control its own loading state by specifying `suspensible: false` in its options.
98+
O componente assíncrono pode cancelar o controle do `Suspense` e deixar que o componente sempre controle seu próprio estado de carregamento, especificando `suspensible: false` em suas opções.
9999

100-
You can check the list of available options in the [API Reference](../api/global-api.html#arguments-4)
100+
Você pode conferir a lista de opções disponíveis na [Referência da API](../api/global-api.html#arguments-4)

0 commit comments

Comments
 (0)