证件号部分内容怎么用星号****代替?


目前总结两种方式实现,话不多说,直接上代码。。。

1、通过substr()方法实现

  

 1 <script>
 2     export default {
 3         data() {
 4             return {
 5                 hideCode: '',
 6                 code: '232301222222228888'
 7             }
 8         },
 9         computed: {
10 
11         },
12         onLoad() {
13             this.hideCode = this.code.substr(0,6) + '********' + this.code.substr(14,17) 
14         },
15         methods: {
16             
17         }
18     }
19 </script>

2、通过正则表达式实现

          this.hideCode = this.code.replace(/^(\d{6})\d{8}(\d+)/,"$1********$2")

效果:

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM