小程序身份证号码保留前后4位其他用“*”代替
wxml
<text>{{cardID}}</text>
js
data: {
cardID: "440923199911111234",
},
// 身份证号码保留前后4位,其他用*代替
onLoad:function () {
this.setData({
cardID: this.data.cardID.substr(0, 4) + "*".repeat(this.data.cardID.length - 8) + this.data.cardID.substr(-4)
})
console.log(this.data.cardID);
},