Skip to content
On this page

Desensitization 脱敏

基本使用

默认******字符
默认******字符
基本使用
<template>
  <www-desensitization>默认保留前后2个字符</www-desensitization>
  <www-desensitization value="默认保留前后2个字符" />
</template>

<script lang="ts" setup>
</script>

<style scoped lang="scss">
</style>
<template>
  <www-desensitization>默认保留前后2个字符</www-desensitization>
  <www-desensitization value="默认保留前后2个字符" />
</template>

<script lang="ts" setup>
</script>

<style scoped lang="scss">
</style>

带有label字段

张三******张三
带有label字段
<template>
  <www-desensitization label="姓名:">张三</www-desensitization>
</template>

<script lang="ts" setup>
</script>

<style scoped lang="scss">
</style>
<template>
  <www-desensitization label="姓名:">张三</www-desensitization>
</template>

<script lang="ts" setup>
</script>

<style scoped lang="scss">
</style>

预设类型

字段说明类型描述
idCard身份证号string前四后二脱敏
phone手机号string前三后二脱敏
number编号string前二后二脱敏
password密码string全脱敏
132******22
1301******333
10******40
******
预设类型
<template>
  <www-desensitization type="phone" label="手机号:">13260462222</www-desensitization>
  <www-desensitization type="idCard" label="身份证号:">130121111111113333</www-desensitization>
  <www-desensitization type="number" label="编码:">1001494100983152640</www-desensitization>
  <www-desensitization type="password" label="密码:">1001494100983152640</www-desensitization>
</template>

<script lang="ts" setup>
</script>

<style scoped lang="scss">
</style>
<template>
  <www-desensitization type="phone" label="手机号:">13260462222</www-desensitization>
  <www-desensitization type="idCard" label="身份证号:">130121111111113333</www-desensitization>
  <www-desensitization type="number" label="编码:">1001494100983152640</www-desensitization>
  <www-desensitization type="password" label="密码:">1001494100983152640</www-desensitization>
</template>

<script lang="ts" setup>
</script>

<style scoped lang="scss">
</style>
12******33
预设类型
<template>
  <www-desensitization>
    <div><div>1233</div><div>123</div></div>
  </www-desensitization>
</template>

<script lang="ts" setup>
</script>

<style scoped lang="scss">
</style>
<template>
  <www-desensitization>
    <div><div>1233</div><div>123</div></div>
  </www-desensitization>
</template>

<script lang="ts" setup>
</script>

<style scoped lang="scss">
</style>

自定义显示位数

******
自定义显示位数
TODO:未实现
<template>
  <www-desensitization
    type="1"
    label="手机号:"
    value="13812345678"
    beforLen="2"
    afterLen="-1"
  />
</template>

<script lang="ts" setup>
</script>

<style scoped lang="scss">
</style>
<template>
  <www-desensitization
    type="1"
    label="手机号:"
    value="13812345678"
    beforLen="2"
    afterLen="-1"
  />
</template>

<script lang="ts" setup>
</script>

<style scoped lang="scss">
</style>

组件 API

Attributes 属性

参数说明类型可选值默认值
labellabel字段stringstringnull
type类型stringidCard phone number passwordpassword
length长度numbernumber6
iconSize字体numbernumber16(rpx)
dot占位stringstring'*'
value正文stringstring
beforLen显示字符个数numbernumber0
afterLen显示字符个数numbernumber0

Methods 方法

方法名说明参数返回值

Events 事件

事件名说明参数返回值

Slots 插槽

插槽名说明参数