Skip to content

Commit a86a738

Browse files
authored
docs: translate guide/migration/v-model.md
1 parent 8e1c7a2 commit a86a738

File tree

1 file changed

+48
-47
lines changed

1 file changed

+48
-47
lines changed

src/guide/migration/v-model.md

Lines changed: 48 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 usados em componentes customizados, `v-model` o nome padrão da propriedade e do evento 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` no que existia no `v-bind` e sua aplicação no componente `model` foram subistituidos pelo`v-model` com um argumento;
16+
- **NOVO:** Multiplas atribuições 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 a 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 do componente `model` que permite ao componente personalizar a propriedade e o evento para usar no` v-model`. No entanto, isso ainda 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+
## 2.x Sintaxe
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 2.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 quisermos mudar os nomes da propriedade ou evento para algo diferente, precisaremos adicionar uma opção `model` ao componente `ChildComponent`:
4242

4343
```html
4444
<!-- ParentComponent.vue -->
@@ -55,78 +55,79 @@ 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 um propiedade (à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+
## 3.x Sintaxe
96+
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`:
9698

97-
In 3.x `v-model` on the custom component is an equivalent of passing a `modelValue` prop and emitting an `update:modelValue` event:
9899

99100
```html
100101
<ChildComponent v-model="pageTitle" />
101102

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

104105
<ChildComponent
105106
:modelValue="pageTitle"
106107
@update:modelValue="pageTitle = $event"
107108
/>
108109
```
109110

110-
### `v-model` arguments
111+
### `v-model` argumentos
111112

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

114115
```html
115116
<ChildComponent v-model:title="pageTitle" />
116117

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

119120
<ChildComponent :title="pageTitle" @update:title="pageTitle = $event" />
120121
```
121122

122123
![v-bind anatomy](/images/v-bind-instead-of-sync.png)
123124

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

126127
```html
127128
<ChildComponent v-model:title="pageTitle" v-model:content="pageContent" />
128129

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

131132
<ChildComponent
132133
:title="pageTitle"
@@ -136,31 +137,31 @@ This also serves as a replacement to `.sync` modifier and allows us to have mult
136137
/>
137138
```
138139

139-
### `v-model` modifiers
140+
### `v-model` modificadores
140141

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

143144
```html
144145
<ChildComponent v-model.capitalize="pageTitle" />
145146
```
146147

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

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

151-
We recommend:
152+
Nós recomedamos:
152153

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

155156
```html
156157
<ChildComponent :title.sync="pageTitle" />
157158

158-
<!-- to be replaced with -->
159+
<!-- subistituir por -->
159160

160161
<ChildComponent v-model:title="pageTitle" />
161162
```
162-
163-
- for all `v-model`s without arguments, make sure to change props and events name to `modelValue` and `update:modelValue` respectively
163+
164+
- para todos os `v-model`s sem argumento, certifique-se de alterar o nome das propriedades e eventos para `modelValue` e `update:modelValue` respectivamente
164165

165166
```html
166167
<ChildComponent v-model="pageTitle" />
@@ -171,20 +172,20 @@ We recommend:
171172

172173
export default {
173174
props: {
174-
modelValue: String // previously was `value: String`
175+
modelValue: String // anteriormente era `value: String`
175176
},
176177
methods: {
177178
changePageTitle(title) {
178-
this.$emit('update:modelValue', title) // previously was `this.$emit('input', title)`
179+
this.$emit('update:modelValue', title) // anteriormente era `this.$emit('input', title)`
179180
}
180181
}
181182
}
182183
```
183184

184-
## Next Steps
185+
## Próximos passos
185186

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

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)
189+
- [Utilizando `v-model` nos componentes](../component-basics.html#using-v-model-on-components)
190+
- [Argumentos `v-model`](../component-custom-events.html#v-model-arguments)
191+
- [Tratando modificadores do `v-model`](../component-custom-events.html#v-model-arguments)

0 commit comments

Comments
 (0)