Add .undefined
modifier to vue-model
#659
CaseyHofland
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
This is a feature request that was asked for back in Vue 2
I would like to reopen it with a slight alteration because it would be a great feature. For some input fields, usually numbers and text, we would like our model to be set to
undefined
when the user does not provide any input. However, the current implementation is that the input resets to0
for numbers and""
for text.The current quick fix is to add a
watchEffect
for converting0
toundefined
, but that doesn't allow for0
as a valid input.A much more elegant solution would be to have a modifier
.undefined
(and sibling modifier.null
) to handle this for you. It would look like this:I know there has been asked for custom modifiers as a feature, but even if that goes through I would still like to see this added in native Vue. It would remove a lot of headaches around data-formatting, and nobody would have to reinvent the wheel when they stumble against this problem again.
Beta Was this translation helpful? Give feedback.
All reactions