How to use mask in vuetify text-field?

随声附和 提交于 2019-11-30 01:40:46

问题


I'm trying to use the mask property of text-field component, like the example below. In the view, that works like a charm, but, when the form is posted, the mask format does not keep the value.

For example, when I type "000.000.000-00", the value that the form posted was "00000000000". How can I keep the format value?

<v-text-field
  :value="currentValue" 
  @input="handleInput"
  :mask="###.###.###-##"></v-text-field>

回答1:


You can use return-masked-value prop

<v-text-field
    :value="currentValue" 
    return-masked-value
    mask="###.###.###-##"
    @input="handleInput"
></v-text-field>

Note that currently in v0.17 there is a bug with returning unmasked initial value.



来源:https://stackoverflow.com/questions/47857673/how-to-use-mask-in-vuetify-text-field

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!