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 usados em componentes customizados, `v-model`o nome padrão da propriedade e do evento 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`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`.
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 a 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 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.
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
+
## 2.x Sintaxe
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 2.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 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:
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 +137,31 @@ This also serves as a replacement to `.sync` modifier and allows us to have mult
136
137
/>
137
138
```
138
139
139
-
### `v-model`modifiers
140
+
### `v-model`modificadores
140
141
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:
142
143
143
144
```html
144
145
<ChildComponentv-model.capitalize="pageTitle" />
145
146
```
146
147
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).
148
149
149
-
## Migration Strategy
150
+
## Estratégia de Migração
150
151
151
-
We recommend:
152
+
Nós recomedamos:
152
153
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`:
154
155
155
156
```html
156
157
<ChildComponent:title.sync="pageTitle" />
157
158
158
-
<!--to be replaced with-->
159
+
<!--subistituir por-->
159
160
160
161
<ChildComponentv-model:title="pageTitle" />
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
+
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
164
165
165
166
```html
166
167
<ChildComponentv-model="pageTitle" />
@@ -171,20 +172,20 @@ We recommend:
171
172
172
173
exportdefault {
173
174
props: {
174
-
modelValue:String//previously was `value: String`
175
+
modelValue:String//anteriormente era `value: String`
175
176
},
176
177
methods: {
177
178
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)`
179
180
}
180
181
}
181
182
}
182
183
```
183
184
184
-
## Next Steps
185
+
## Próximos passos
185
186
186
-
For more information on the new `v-model` syntax, see:
187
+
Para mais informações na nova sintaxe do `v-model`, veja:
0 commit comments