You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-**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:
13
13
- prop: `value` -> `modelValue`;
14
14
- 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`.
18
18
19
-
For more information, read on!
19
+
Para mais informações, continue lendo!
20
20
21
-
## Introduction
21
+
## Introdução
22
22
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.
24
24
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.
26
26
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`.
28
28
29
-
## 2.x Syntax
29
+
## Sintaxe v2.x
30
30
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`:
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:
78
78
79
79
```js
80
80
this.$emit('update:title', newValue)
81
81
```
82
82
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:
@@ -136,31 +136,31 @@ This also serves as a replacement to `.sync` modifier and allows us to have mult
136
136
/>
137
137
```
138
138
139
-
### `v-model` modifiers
139
+
### Modificadores do `v-model`
140
140
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:
142
142
143
143
```html
144
144
<ChildComponentv-model.capitalize="pageTitle" />
145
145
```
146
146
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).
148
148
149
-
## Migration Strategy
149
+
## Estratégia de Migração
150
150
151
-
We recommend:
151
+
Nós recomendamos:
152
152
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`:
154
154
155
155
```html
156
156
<ChildComponent:title.sync="pageTitle" />
157
157
158
-
<!--to be replaced with-->
158
+
<!--substituir por-->
159
159
160
160
<ChildComponentv-model:title="pageTitle" />
161
161
```
162
162
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
164
164
165
165
```html
166
166
<ChildComponentv-model="pageTitle" />
@@ -171,20 +171,20 @@ We recommend:
171
171
172
172
exportdefault {
173
173
props: {
174
-
modelValue:String//previously was `value: String`
174
+
modelValue:String//anteriormente era `value: String`
175
175
},
176
176
methods: {
177
177
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)`
179
179
}
180
180
}
181
181
}
182
182
```
183
183
184
-
## Next Steps
184
+
## Próximos Passos
185
185
186
-
For more information on the new `v-model` syntax, see:
186
+
Para mais informações na nova sintaxe do `v-model`, veja:
0 commit comments