通过几行代码实现手机号格式化,形如132*******464
//友好展示电话号码
setPhone(){
let Phone = '13245678464'
let phone = Phone.replace(/(\d{3})(\d{4})(\d{4})/, "$1****$3")
this.setData({
phone: phone
})
}
以下为页面显示效果:
//友好展示电话号码
setPhone(){
let Phone = '13245678464'
let phone = Phone.replace(/(\d{3})(\d{4})(\d{4})/, "$1****$3")
this.setData({
phone: phone
})
}
以下为页面显示效果: