如何在 vuetify 文本字段中使用掩码? [英] How to use mask in vuetify text-field?

查看:25
本文介绍了如何在 vuetify 文本字段中使用掩码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用文本字段组件的掩码属性,如下例所示.在视图中,这就像一个魅力,但是,当表单发布时,掩码格式不保留值.

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.

例如,当我输入000.000.000-00"时,表单发布的值为00000000000".如何保留格式值?

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="###.###.###-##"/>

推荐答案

在 Vuetify 中删除了 2 个遮罩


Vuetify 版本的答案

2.0.0

您可以使用 return-masked-value 道具

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

<小时>

请注意,目前在 v0.17 存在一个错误 返回未屏蔽的初始值.


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

这篇关于如何在 vuetify 文本字段中使用掩码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆