js身份證號、電話脫敏處理(用*替換中間數據)


數字類型

certificatecodecopy = certificatecode.replace(/^(.{6})(?:\d+)(.{4})$/,  "\$1****\$2");

所有類型

enginenocopy = engineno.replace(/^(.{2})(?:\w+)(.{1})$/, "\$1****\$2");

enginenocopy = engineno.replace(/^(.{4})(?:\w+)(.{4})$/, "\$1****\$2");

vue中應用

<el-table-column
                  width="200px"
                  prop="credentialsNum"
                  label="身份證號碼"
                  align="center"
                >
                  <template slot-scope="scope">
                  <p v-if="scope.row.credentialsNum != null && scope.row.credentialsNum != '' "> {{scope.row.credentialsNum.replace(/^(.{6})(?:\d+)(.{4})$/, "$1****$2")}} </p>
                  <p v-else>未知</p>
                  </template>
                </el-table-column>

效果圖:


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM