Add custom v-model modifiers
See original GitHub issueWe have .lazy
, .number
, .trim
and .undef
is on the way.
Apart from .lazy
they all work like two-way filters.
Since 2.0 does not support 2 way filters, may be there should be a new api to add custom v-model modifiers to fulfill the same need.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:53
- Comments:52 (10 by maintainers)
Top Results From Across the Web
Vue Tip: Create Custom v-model Modifier - Michael Hoffmann
v -model has some built-in modifiers, but in some cases, you might need to add your custom modifier.
Read more >How create a v-model modifier to a VueJS Component?
First, adding adding a custom modified to v-model is under discussion but not yet implemented. If it was implemented, you could extend the ......
Read more >Form Input Bindings - Vue.js
v -model will ignore the initial value , checked or selected attributes found on any form elements. It will always treat the current...
Read more >What you should know about Vue v-model - LearnVue
When we use a custom model name, the name of the emitted method will be update:name and the prop passed will be name...
Read more >Vue 3 v-model modifiers - by nick_somebody - The VuesPaper
This time we'll be covering the ability to add your own modifiers to a component's v-model . Modifiers were a feature in Vue...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Any chance we can get this issue reopened? A common use case for me is the need to automatically format data in a field as it’s being typed in. Something like taking ‘101216’ and turning it into ‘10/12/16’. Being able to create a custom v-model modifier would greatly simplify my code since I could write v-model.date instead of having to build a custom input component with props and events.
+1 for custom modifiers. Seems like a no brainer, unless there is a good reason not to?
Masking input and parsing the value for application use is a very common practice, and making some “syntatic sugar” like v-model.lazy.currency=“amount” would be amazing!