Skip to content

TextMask 文本脱敏

用于对文本进行部分隐藏,保护敏感信息。

基础用法

通过 startend 控制保留的字符数。

预设类型

支持多种常见的敏感数据类型,如手机号、邮箱、身份证等。

自定义掩码字符

使用 mask-char 属性自定义掩码符号,例如使用 "●" 或 "-"。

点击查看

设置 allow-reveal 属性,允许用户点击文本切换显示/隐藏原始文本。此时鼠标悬停会变为手型,且有颜色变化提示。

TextMask API

TextMask Attributes

属性名说明类型默认值
content需要脱敏的文本内容string-
type脱敏类型,可选值: mobile, email, id-card, bank-card, name, all, customstringcustom
start头部保留的字符数(在 custom 模式下生效)number0
end尾部保留的字符数(在 custom 模式下生效)number0
mask-char掩码字符string*
allow-reveal是否允许点击查看原文本booleanfalse