Skip to content

Commit 0a40155

Browse files
authored
Merge pull request #174 from Renato66/patch-1
docs: translate guide/migration/v-model.md
2 parents 755119e + 4aab08e commit 0a40155

File tree

1 file changed

+47
-47
lines changed

1 file changed

+47
-47
lines changed

src/guide/migration/v-model.md

Lines changed: 47 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -5,40 +5,40 @@ badges:
55

66
# `v-model` <MigrationBadges :badges="$frontmatter.badges" />
77

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

10-
In terms of what has changed, at a high level:
10+
Olhando por cima o que mudou:
1111

12-
- **BREAKING:** When used on custom components, `v-model` prop and event default names are changed:
12+
- **QUEBRA:** Quando usado em componentes customizados, o nome padrão da propriedade e do evento do `v-model` mudaram:
1313
- prop: `value` -> `modelValue`;
1414
- event: `input` -> `update:modelValue`;
15-
- **BREAKING:** `v-bind`'s `.sync` modifier and component `model` option are removed and replaced with an argument on `v-model`;
16-
- **NEW:** Multiple `v-model` bindings on the same component are possible now;
17-
- **NEW:** Added the ability to create custom `v-model` modifiers.
15+
- **QUEBRA:** O modificador `.sync` que existia no `v-bind` e a opção `model` de componentes foram substituídos pelo `v-model` com um argumento;
16+
- **NOVO:** Múltiplos vínculos do `v-model` no mesmo componente são possíveis agora;
17+
- **NOVO:** Adicionado a possibilidade de criar modificadores para o `v-model`.
1818

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

21-
## Introduction
21+
## Introdução
2222

23-
When Vue 2.0 was released, the `v-model` directive required developers to always use the `value` prop. And if developers required different props for different purposes, they would have to resort to using `v-bind.sync`. In addition, this hard-coded relationship between `v-model` and `value` led to issues with how native elements and custom elements were handled.
23+
Quando o Vue 2.0 foi lançado, a diretiva `v-model` exigia para os desenvolvedores sempre usar a propriedade `value`. E se os desenvolvedores precisassem usar uma propriedade diferente para um outro propósito, eles deveriam recorrer ao uso do `v-bind.sync`. Além disso, essa relação fixa entre `v-model` e` value` levou à problemas com a forma como os elementos nativos e personalizados eram tratados.
2424

25-
In 2.2 we introduced the `model` component option that allows the component to customize the prop and event to use for `v-model`. However, this still only allowed a single `v-model` to be used on the component.
25+
Na versão 2.2, introduzimos a opção de componente `model` que permite ao componente personalizar a propriedade e o evento para usar no `v-model`. No entanto, isso ainda apenas permitia que um único `v-model` fosse usado no componente.
2626

27-
With Vue 3, the API for two-way data binding is being standardized in order to reduce confusion and to allow developers more flexibility with the `v-model` directive.
27+
Com o Vue 3, a API para vinculação de dados bidirecional está sendo padronizada para reduzir a confusão e permitir aos desenvolvedores mais flexibilidade com a diretiva `v-model`.
2828

29-
## 2.x Syntax
29+
## Sintaxe v2.x
3030

31-
In 2.x, using a `v-model` on a component was an equivalent of passing a `value` prop and emitting an `input` event:
31+
Na v2.x, usando um `v-model` em um componente era equivalente a passar uma propriedade `value` e emitir um evento `input`:
3232

3333
```html
3434
<ChildComponent v-model="pageTitle" />
3535

36-
<!-- would be shorthand for: -->
36+
<!-- seria um atalho para: -->
3737

3838
<ChildComponent :value="pageTitle" @input="pageTitle = $event" />
3939
```
4040

41-
If we wanted to change prop or event names to something different, we would need to add a `model` option to `ChildComponent` component:
41+
Se quiséssemos mudar os nomes da propriedade ou evento para algo diferente, precisaríamos adicionar uma opção `model` ao componente `ChildComponent`:
4242

4343
```html
4444
<!-- ParentComponent.vue -->
@@ -55,78 +55,78 @@ export default {
5555
event: 'change'
5656
},
5757
props: {
58-
// this allows using the `value` prop for a different purpose
58+
// isso permite a utilização da propriedade `value` para um propósito diferente
5959
value: String,
60-
// use `title` as the prop which take the place of `value`
60+
// utilizando `title` como uma propriedade que irá tomar o lugar do `value`
6161
title: {
6262
type: String,
63-
default: 'Default title'
63+
default: 'Título padrão'
6464
}
6565
}
6666
}
6767
```
6868

69-
So, `v-model` in this case would be a shorthand to
69+
Então, o `v-model` nesse caso seria um atalho para:
7070

7171
```html
7272
<ChildComponent :title="pageTitle" @change="pageTitle = $event" />
7373
```
7474

75-
### Using `v-bind.sync`
75+
### Usando `v-bind.sync`
7676

77-
In some cases, we might need "two-way binding" for a prop (sometimes in addition to existing `v-model` for the different prop). To do so, we recommended emitting events in the pattern of `update:myPropName`. For example, for `ChildComponent` from the previous example with the `title` prop, we could communicate the intent of assigning a new value with:
77+
Em alguns casos, podemos precisar de uma "ligação bidirecional" para uma propriedade (às vezes além do `v-model` existente para uma propriedade diferente). Para fazer isso, recomendamos a emissão de eventos no padrão de `update:myPropName`. Por exemplo, para `ChildComponent` do exemplo anterior com a propriedade `title`, poderíamos comunicar a intenção de atribuir um novo valor com:
7878

7979
```js
8080
this.$emit('update:title', newValue)
8181
```
8282

83-
Then the parent could listen to that event and update a local data property, if it wants to. For example:
83+
Em seguida, o pai pode ouvir esse evento e atualizar uma propriedade de dados local, se quiser. Por exemplo:
8484

8585
```html
8686
<ChildComponent :title="pageTitle" @update:title="pageTitle = $event" />
8787
```
8888

89-
For convenience, we had a shorthand for this pattern with the .sync modifier:
89+
Por conveniência, tínhamos uma abreviatura para esse padrão com o modificador .sync:
9090

9191
```html
9292
<ChildComponent :title.sync="pageTitle" />
9393
```
9494

95-
## 3.x Syntax
95+
## Sintaxe v3.x
9696

97-
In 3.x `v-model` on the custom component is an equivalent of passing a `modelValue` prop and emitting an `update:modelValue` event:
97+
Na versão 3.x o `v-model` em um componente personalizado é equivalente a passar um prop `modelValue` e emitir um evento `update:modelValue`:
9898

9999
```html
100100
<ChildComponent v-model="pageTitle" />
101101

102-
<!-- would be shorthand for: -->
102+
<!-- seria um atalho para: -->
103103

104104
<ChildComponent
105105
:modelValue="pageTitle"
106106
@update:modelValue="pageTitle = $event"
107107
/>
108108
```
109109

110-
### `v-model` arguments
110+
### Argumentos do `v-model`
111111

112-
To change a model name, instead of a `model` component option, now we can pass an _argument_ to `v-model`:
112+
Para alterar o nome de um modelo, em vez de uma opção de componente `model`, agora podemos passar um _argumento_ para` v-model`:
113113

114114
```html
115115
<ChildComponent v-model:title="pageTitle" />
116116

117-
<!-- would be shorthand for: -->
117+
<!-- seria um atalho para: -->
118118

119119
<ChildComponent :title="pageTitle" @update:title="pageTitle = $event" />
120120
```
121121

122-
![v-bind anatomy](/images/v-bind-instead-of-sync.png)
122+
![Anatomia do v-bind](/images/v-bind-instead-of-sync.png)
123123

124-
This also serves as a replacement to `.sync` modifier and allows us to have multiple `v-model`s on the custom component.
124+
Isso também serve como um substituto para o modificador `.sync` e nos permite ter vários `v-model`s no componente personalizado.
125125

126126
```html
127127
<ChildComponent v-model:title="pageTitle" v-model:content="pageContent" />
128128

129-
<!-- would be shorthand for: -->
129+
<!-- seria um atalho para: -->
130130

131131
<ChildComponent
132132
:title="pageTitle"
@@ -136,31 +136,31 @@ This also serves as a replacement to `.sync` modifier and allows us to have mult
136136
/>
137137
```
138138

139-
### `v-model` modifiers
139+
### Modificadores do `v-model`
140140

141-
In addition to 2.x hard-coded `v-model` modifiers like `.trim`, now 3.x supports custom modifiers:
141+
Além dos modificadores do `v-model` fixos já existentes na v2.x, como `.trim`, agora v3.x suporta modificadores personalizados:
142142

143143
```html
144144
<ChildComponent v-model.capitalize="pageTitle" />
145145
```
146146

147-
Read more about custom `v-model` modifiers in the [Custom Events](../component-custom-events.html#handling-v-model-modifiers) section.
147+
Leia mais sobre modificadores do `v-model` customizados na seção [Eventos Customizados](../component-custom-events.html#handling-v-model-modifiers).
148148

149-
## Migration Strategy
149+
## Estratégia de Migração
150150

151-
We recommend:
151+
Nós recomendamos:
152152

153-
- checking your codebase for `.sync` usage and replace it with `v-model`:
153+
- verificar seu código aonde utilizado o `.sync` e substituí-lo por `v-model`:
154154

155155
```html
156156
<ChildComponent :title.sync="pageTitle" />
157157

158-
<!-- to be replaced with -->
158+
<!-- substituir por -->
159159

160160
<ChildComponent v-model:title="pageTitle" />
161161
```
162162

163-
- for all `v-model`s without arguments, make sure to change props and events name to `modelValue` and `update:modelValue` respectively
163+
- para todos os `v-model`s sem argumentos, certifique-se de alterar o nome das propriedades e eventos para `modelValue` e `update:modelValue` respectivamente
164164

165165
```html
166166
<ChildComponent v-model="pageTitle" />
@@ -171,20 +171,20 @@ We recommend:
171171

172172
export default {
173173
props: {
174-
modelValue: String // previously was `value: String`
174+
modelValue: String // anteriormente era `value: String`
175175
},
176176
methods: {
177177
changePageTitle(title) {
178-
this.$emit('update:modelValue', title) // previously was `this.$emit('input', title)`
178+
this.$emit('update:modelValue', title) // anteriormente era `this.$emit('input', title)`
179179
}
180180
}
181181
}
182182
```
183183

184-
## Next Steps
184+
## Próximos Passos
185185

186-
For more information on the new `v-model` syntax, see:
186+
Para mais informações na nova sintaxe do `v-model`, veja:
187187

188-
- [Using `v-model` on Components](../component-basics.html#using-v-model-on-components)
189-
- [`v-model` arguments](../component-custom-events.html#v-model-arguments)
190-
- [Handling `v-model` modifiers](../component-custom-events.html#v-model-arguments)
188+
- [Utilizando `v-model` em Componentes](../component-basics.html#using-v-model-on-components)
189+
- [Argumentos do `v-model`](../component-custom-events.html#v-model-arguments)
190+
- [Tratando modificadores do `v-model`](../component-custom-events.html#v-model-arguments)

0 commit comments

Comments
 (0)