Skip to content

Commit 0055b8e

Browse files
authored
Merge pull request #196 from romulo1984/docs/sfc
Translation of the 'single-file-component' file of the docs
2 parents 33f5b71 + 3a05e93 commit 0055b8e

File tree

1 file changed

+33
-33
lines changed

1 file changed

+33
-33
lines changed

src/guide/single-file-component.md

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,67 @@
1-
# Single File Components
1+
# Componentes Single-File
22

3-
## Introduction
3+
## Introdução
44

5-
In many Vue projects, global components will be defined using `app.component()`, followed by `app.mount('#app')` to target a container element in the body of every page.
5+
Em muitos projetos Vue, os componentes globais serão definidos usando `app.component()`, seguido por `app.mount('#app')` mirando em um elemento contêiner no corpo de cada página.
66

7-
This can work very well for small to medium-sized projects, where JavaScript is only used to enhance certain views. In more complex projects however, or when your frontend is entirely driven by JavaScript, these disadvantages become apparent:
7+
Isto pode funcionar bem em projetos pequenos e médios, onde o JavaScript só é utilizado para incrementar certas interfaces. No entanto, em projetos mais complexos ou quando o _frontend_ é totalmente orientado pelo JavaScript, tais desvantagens se tornam aparentes:
88

9-
- **Global definitions** force unique names for every component
10-
- **String templates** lack syntax highlighting and require ugly slashes for multiline HTML
11-
- **No CSS support** means that while HTML and JavaScript are modularized into components, CSS is conspicuously left out
12-
- **No build step** restricts us to HTML and ES5 JavaScript, rather than preprocessors like Pug (formerly Jade) and Babel
9+
- **Definições globais** forçam nomes únicos para cada componente
10+
- **Templates com Strings** não têm realce de sintaxe e são difíceis de ler em múltiplas linhas
11+
- **Sem suporte ao CSS** enquanto HTML e JavaScript são modularizados em componentes, CSS é notavelmente deixado de fora
12+
- **Sem processamento no build** ou seja, nos restringindo a HTML e JavaScript ES5, em vez de pré-processadores como Pug (anteriormente Jade) e Babel
1313

14-
All of these are solved by **single-file components** with a `.vue` extension, made possible with build tools such as Webpack or Browserify.
14+
Tudo isso é resolvido através dos **Componentes Single-File** com a extensão `.vue`, possibilitados graças a ferramentas de _build_ como Webpack ou Browserify.
1515

16-
Here's an example of a file we'll call `Hello.vue`:
16+
Aqui está um exemplo de um arquivo que chamaremos de `Hello.vue`:
1717

18-
<a href="https://codepen.io/team/Vue/pen/3de13b5cd0133df4ecf307b6cf2c5f94" target="_blank" rel="noopener noreferrer"><img src="/images/sfc.png" width="403" alt="Single-file component example (click for code as text)" style="display: block; margin: 15px auto; max-width: 100%"></a>
18+
<a href="https://codepen.io/team/Vue/pen/3de13b5cd0133df4ecf307b6cf2c5f94" target="_blank" rel="noopener noreferrer"><img src="/images/sfc.png" width="403" alt="Exemplo de componente single-file (clique para ver o código em texto)" style="display: block; margin: 15px auto; max-width: 100%"></a>
1919

20-
Now we get:
20+
Agora nós obtivemos:
2121

22-
- [Complete syntax highlighting](https://github.com/vuejs/awesome-vue#source-code-editing)
23-
- [CommonJS modules](https://webpack.js.org/concepts/modules/#what-is-a-webpack-module)
24-
- [Component-scoped CSS](https://vue-loader.vuejs.org/en/features/scoped-css.html)
22+
- [Realce de sintaxe completo](https://github.com/vuejs/awesome-vue#source-code-editing)
23+
- [Módulos tipo CommonJS](https://webpack.js.org/concepts/modules/#what-is-a-webpack-module)
24+
- [Escopo de CSS por componente](https://vue-loader.vuejs.org/en/features/scoped-css.html)
2525

26-
As promised, we can also use preprocessors such as Pug, Babel (with ES2015 modules), and Stylus for cleaner and more feature-rich components.
26+
Como prometido, também podemos utilizar pré-processadores como Pug (Jade), Babel (com módulos ES2015+) e Stylus para componentes mais limpos e mais ricos em recursos.
2727

28-
<a href="https://codesandbox.io/s/vue-single-file-component-with-pre-processors-mr3ik?file=/src/App.vue" target="_blank" rel="noopener noreferrer"><img src="/images/sfc-with-preprocessors.png" width="563" alt="Single-file component with pre-processors example (click for code as text)" style="display: block; margin: 15px auto; max-width: 100%"></a>
28+
<a href="https://codesandbox.io/s/vue-single-file-component-with-pre-processors-mr3ik?file=/src/App.vue" target="_blank" rel="noopener noreferrer"><img src="/images/sfc-with-preprocessors.png" width="563" alt="Exemplo de componente single-file com pré-processadores (clique para ver o código em texto)" style="display: block; margin: 15px auto; max-width: 100%"></a>
2929

30-
These specific languages are only examples. You could as easily use TypeScript, SCSS, PostCSS, or whatever other preprocessors that help you be productive. If using Webpack with `vue-loader`, it also has first-class support for CSS Modules.
30+
Estas linguagens específicas são meros exemplos. Poderíamos tão facilmente usar TypeScript, SCSS, PostCSS - ou qualquer outro que acreditarmos nos tornar mais produtivos. Se usar Webpack com `vue-loader`, também há suporte de primeira classe a CSS Modules.
3131

32-
### What About Separation of Concerns?
32+
### E a Separação de Responsabilidades?
3333

34-
One important thing to note is that **separation of concerns is not equal to separation of file types.** In modern UI development, we have found that instead of dividing the codebase into three huge layers that interweave with one another, it makes much more sense to divide them into loosely-coupled components and compose them. Inside a component, its template, logic and styles are inherently coupled, and collocating them actually makes the component more cohesive and maintainable.
34+
Uma coisa importante a observar é que **separação de responsabilidades não é igual a separação de tipos de arquivo**. No desenvolvimento moderno de interfaces, chegamos à conclusão de que, ao invés de dividir a base de código em três grandes camadas que se entrelaçam umas com as outras, faz muito mais sentido dividi-las em componentes fracamente acoplados e utilizá-los para composição. Dentro de um componente, seu template, sua lógica e seus estilos são inerentemente acoplados, e encará-los dessa forma os torna componentes mais coesos e manuteníveis.
3535

36-
Even if you don't like the idea of Single-File Components, you can still leverage its hot-reloading and pre-compilation features by separating your JavaScript and CSS into separate files:
36+
Se mesmo assim não gostar da ideia de Componentes _Single-File_, você ainda pode tirar vantagem de seus recursos de _hot-reloading_ (recompilação e atualização em tempo real ao salvar o código) e de pré-compilação, separando JavaScript e CSS em arquivos distintos:
3737

3838
```html
3939
<!-- my-component.vue -->
4040
<template>
41-
<div>This will be pre-compiled</div>
41+
<div>Isso será pré-compilado</div>
4242
</template>
4343
<script src="./my-component.js"></script>
4444
<style src="./my-component.css"></style>
4545
```
4646

47-
## Getting Started
47+
## Primeiros Passos
4848

49-
### Example Sandbox
49+
### Sandbox de Exemplo
5050

51-
If you want to dive right in and start playing with single-file components, check out [this simple todo app](https://codesandbox.io/s/vue-todo-list-app-with-single-file-component-vzkl3?file=/src/App.vue) on CodeSandbox.
51+
Se você quiser se mergulhar agora mesmo e começar a brincar com Componentes _Single-File_, dê uma olhada [neste aplicativo de lista de tarefas simples](https://codesandbox.io/s/vue-todo-list-app-with-single-file-component-vzkl3?file=/src/App.vue) no CodeSandbox.
5252

53-
### For Users New to Module Build Systems in JavaScript
53+
### Para Iniciantes em Empacotadores JS
5454

55-
With `.vue` components, we're entering the realm of advanced JavaScript applications. That means learning to use a few additional tools if you haven't already:
55+
Com componentes `.vue`, estamos entrando no reino das aplicações JavaScript avançadas. Significa aprender a utilizar algumas ferramentas adicionais se ainda não teve oportunidade:
5656

57-
- **Node Package Manager (npm)**: Read the [Getting Started guide](https://docs.npmjs.com/packages-and-modules/getting-packages-from-the-registry) section about how to get packages from the registry.
57+
- **Node Package Manager (npm)**: Leia o guia de [Primeiros Passos](https://docs.npmjs.com/packages-and-modules/getting-packages-from-the-registry) do NPM na seção sobre como obter pacotes do registro.
5858

59-
- **Modern JavaScript with ES2015/16**: Read through Babel's [Learn ES2015 guide](https://babeljs.io/docs/en/learn). You don't have to memorize every feature right now, but keep this page as a reference you can come back to.
59+
- **JavaScript Moderno com ES2015/16**: Leia o guia [Aprendendo ES2015](https://babeljs.io/docs/en/learn) do Babel. Não é necessário memorizar cada recurso agora, mas mantenha esta página como referência.
6060

61-
After you've taken a day to dive into these resources, we recommend checking out [Vue CLI](https://cli.vuejs.org/). Follow the instructions and you should have a Vue project with `.vue` components, ES2015, webpack and hot-reloading in no time!
61+
Depois que tiver tirado um dia para mergulhar nestes tópicos, recomendamos dar uma olhada no [Vue CLI](https://cli.vuejs.org/). Seguindo as instruções, você terá em mãos um projeto Vue com componentes `.vue`, ES2015, Webpack e _hot-reloading_, rodando em pouquíssimo tempo!
6262

63-
### For Advanced Users
63+
### Para Usuários Avançados
6464

65-
The CLI takes care of most of the tooling configurations for you, but also allows fine-grained customization through its own [config options](https://cli.vuejs.org/config/).
65+
A CLI cuida da maioria das configurações de ferramentas para você, mas também permite a personalização refinada através de suas próprias [opções de configuração](https://cli.vuejs.org/config/).
6666

67-
In case you prefer setting up your own build setup from scratch, you will need to manually configure webpack with [vue-loader](https://vue-loader.vuejs.org). To learn more about webpack itself, check out [their official docs](https://webpack.js.org/configuration/) and [webpack learning academy](https://webpack.academy/p/the-core-concepts).
67+
Caso você prefira configurar seu próprio _build_ a partir do zero, você precisará configurar manualmente o Webpack com o [vue-loader](https://vue-loader.vuejs.org). Para saber mais sobre o Webpack, confira os [documentos oficiais](https://webpack.js.org/configuration/) e a [Webpack Academy](https://webpack.academy/p/the-core-concepts).

0 commit comments

Comments
 (0)