Skip to content

Commit c039c8c

Browse files
authored
Merge pull request #40 from romulo1984/docs/component-attrs
docs: Translate file 'guide/component-attrs'
2 parents 1c9aa8a + 92672f0 commit c039c8c

File tree

1 file changed

+27
-27
lines changed

1 file changed

+27
-27
lines changed

src/guide/component-attrs.md

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
# Non-Prop Attributes
1+
# Atributos Não-Propriedades
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+
> Esta página assume que você já leu o [Básico sobre Componentes](component-basics.md). Leia lá primeiro se você for novo em componentes.
44
5-
A component non-prop attribute is an attribute or event listener that is passed to a component, but does not have a corresponding property defined in [props](component-props) or [emits](component-custom-events.html#defining-custom-events). Common examples of this include `class`, `style`, and `id` attributes. You can access those attributes via `$attrs` property.
5+
Um atributo de componente não-propriedade é um atributo ou ouvinte de evento que é passado para um componente, mas não tem uma propriedade correspondente definida em [props](component-props) ou [emits](component-custom-events.html#defining-custom-events). Os exemplos comuns disto incluem atributos `class`, `style`, e `id`. Você pode acessar esses atributos por meio da propriedade `$attrs`.
66

7-
## Attribute Inheritance
7+
## Herança de Atributos
88

9-
When a component returns a single root node, non-prop attributes will automatically be added to the root node's attributes. For example, in the instance of a date-picker component:
9+
Quando um componente retorna um único nó raiz, atributos não-propriedade serão automaticamente adicionados aos atributos do nó raiz. Por exemplo, na instância de um componente date-picker:
1010

1111
```js
1212
app.component('date-picker', {
@@ -18,19 +18,19 @@ app.component('date-picker', {
1818
})
1919
```
2020

21-
In the event we need to define the status of the date-picker component via a `data-status` property, it will be applied to the root node (i.e., `div.date-picker`).
21+
No caso de precisarmos definir o status do componente date-picker por meio de uma propriedade `data-status`, ele será aplicado ao nó raiz (ou seja, `div.date-picker`).
2222

2323
```html
24-
<!-- Date-picker component with a non-prop attribute -->
24+
<!-- Componente date-picker com um atributo não-propriedade -->
2525
<date-picker data-status="activated"></date-picker>
2626

27-
<!-- Rendered date-picker component -->
27+
<!-- Componente date-picker renderizado -->
2828
<div class="date-picker" data-status="activated">
2929
<input type="datetime" />
3030
</div>
3131
```
3232

33-
Same rule applies to the event listeners:
33+
A mesma regra se aplica aos ouvintes de eventos:
3434

3535
```html
3636
<date-picker @change="submitChange"></date-picker>
@@ -44,21 +44,21 @@ app.component('date-picker', {
4444
})
4545
```
4646

47-
This might be helpful when we have an HTML element with `change` event as a root element of `date-picker`.
47+
Isso pode ser útil quando temos um elemento HTML com um evento `change` como elemento raiz de `date-picker`.
4848

4949
```js
5050
app.component('date-picker', {
5151
template: `
5252
<select>
53-
<option value="1">Yesterday</option>
54-
<option value="2">Today</option>
55-
<option value="3">Tomorrow</option>
53+
<option value="1">Ontem</option>
54+
<option value="2">Hoje</option>
55+
<option value="3">Amanhã</option>
5656
</select>
5757
`
5858
})
5959
```
6060

61-
In this case, `change` event listener is passed from the parent component to the child and it will be triggered on native `<select>` `change` event. We won't need to emit an event from the `date-picker` explicitly:
61+
Nesse caso, o evento `change` é passado do componente pai para o filho e será acionado no evento nativo `change` do `<select>`. Não precisamos emitir um evento de `date-picker` explicitamente:
6262

6363
```html
6464
<div id="date-picker" class="demo">
@@ -70,21 +70,21 @@ In this case, `change` event listener is passed from the parent component to the
7070
const app = Vue.createApp({
7171
methods: {
7272
showChange(event) {
73-
console.log(event.target.value) // will log a value of the selected option
73+
console.log(event.target.value) // exibirá o valor da opção selecionada
7474
}
7575
}
7676
})
7777
```
7878

79-
## Disabling Attribute Inheritance
79+
## Desativando a Herança de Atributos
8080

81-
If you do **not** want a component to automatically inherit attributes, you can set `inheritAttrs: false` in the component's options.
81+
Se você **não** deseja que um componente herde atributos automaticamente, você pode definir `inheritAttrs: false` nas opções do componente.
8282

83-
The common scenario for disabling an attribute inheritance is when attributes need to be applied to other elements besides the root node.
83+
O cenário comum para desativar uma herança de atributo é quando os atributos precisam ser aplicados a outros elementos além do nó raiz.
8484

85-
By setting the `inheritAttrs` option to `false`, you can control to apply to other elements attributes to use the component's `$attrs` property, which includes all attributes not included to component `props` and `emits` properties (e.g., `class`, `style`, `v-on` listeners, etc.).
85+
Ao definir a opção `inheritAttrs` para `false`, você pode controlar a aplicação em outros atributos dos elementos, para que usem a propriedade `$attrs` do componente, que inclui todos os atributos não incluídos às propriedades `props` e `emits` do componente (por exemplo, `class`, `style`, eventos `v-on`, etc.).
8686

87-
Using our date-picker component example from the [previous section]('#attribute-inheritance), in the event we need to apply all non-prop attributes to the `input` element rather than the root `div` element, this can be accomplished by using the `v-bind` shortcut.
87+
Usando nosso exemplo de componente date-picker da [seção anterior](#heranca-de-atributos), no caso de precisarmos aplicar todos os atributos não-propriedade ao elemento `input` em vez do elemento `div` raiz, isso pode ser feito usando o atalho `v-bind`.
8888

8989
```js{5}
9090
app.component('date-picker', {
@@ -97,28 +97,28 @@ app.component('date-picker', {
9797
})
9898
```
9999

100-
With this new configuration, our `data-status` attribute will be applied to our `input` element!
100+
Com esta nova configuração, nosso atributo `data-status` será aplicado ao nosso elemento `input`!
101101

102102
```html
103-
<!-- Date-picker component with a non-prop attribute -->
103+
<!-- Componente date-picker com um atributo não-propriedade -->
104104
<date-picker data-status="activated"></date-picker>
105105

106-
<!-- Rendered date-picker component -->
106+
<!-- Componente date-picker renderizado -->
107107
<div class="date-picker">
108108
<input type="datetime" data-status="activated" />
109109
</div>
110110
```
111111

112-
## Attribute Inheritance on Multiple Root Nodes
112+
## Herança de Atributos em Vários Nós Raízes
113113

114-
Unlike single root node components, components with multiple root nodes do not have an automatic attribute fallthrough behavior. If `$attrs` are not bound explicitly, a runtime warning will be issued.
114+
Ao contrário dos componentes de um único nó raiz, os componentes com vários nós raízes não têm um comportamento de falha de atributo automático. Se `$attrs` não for vinculado explicitamente, um aviso de tempo de execução será emitido.
115115

116116
```html
117117
<custom-layout id="custom-layout" @click="changeValue"></custom-layout>
118118
```
119119

120120
```js
121-
// This will raise a warning
121+
// Isso irá gerar um aviso
122122
app.component('custom-layout', {
123123
template: `
124124
<header>...</header>
@@ -127,7 +127,7 @@ app.component('custom-layout', {
127127
`
128128
})
129129

130-
// No warnings, $attrs are passed to <main> element
130+
// Sem avisos, $attrs são passados para o elemento <main>
131131
app.component('custom-layout', {
132132
template: `
133133
<header>...</header>

0 commit comments

Comments
 (0)