Skip to content

Commit 3c97d52

Browse files
Update description about .number modifier (#1285)
* Update description about .number modifier * Update src/guide/forms.md Co-authored-by: Natalia Tepluhina <tarya.se@gmail.com>
1 parent 4fae0d0 commit 3c97d52

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Diff for: src/guide/forms.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -269,10 +269,10 @@ By default, `v-model` syncs the input with the data after each `input` event (wi
269269
If you want user input to be automatically typecast as a number, you can add the `number` modifier to your `v-model` managed inputs:
270270

271271
```html
272-
<input v-model.number="age" type="number" />
272+
<input v-model.number="age" type="text" />
273273
```
274274

275-
This is often useful, because even with `type="number"`, the value of HTML input elements always returns a string. If the value cannot be parsed with `parseFloat()`, then the original value is returned.
275+
This is often useful when the input type is `text`. If the input type is `number`, Vue can automatically convert the raw string value to a number, and you don't need to add the `.number` modifier to `v-model`. If the value cannot be parsed with `parseFloat()`, then the original value is returned.
276276

277277
### `.trim`
278278

0 commit comments

Comments
 (0)