手机号隐藏

<p>
            <span>手机号:</span>
            {{ telShow ? changetel(userInfo.contactWay) : userInfo.contactWay }}
            <i class="showTel" @click="showTelClick(userInfo.contactWay)">{{
              telShow ? "显示" : "隐藏"
            }}</i>
          </p>
changetel(tel) {
      return getTel(tel);
    },
    //显示手机号
    showTelClick(tel) {
      console.log("tel", tel);
      this.telShow = !this.telShow;
    },
export function getTel(tel) {
  let reg = /^(\d{3})\d{4}(\d{4})$/;
  if (tel) {
    return tel.replace(reg, "$1****$2")
  } else {
    return ""
  }
}
import { formatDate, getTel } from "@/filters/index.js";
posted @ 2022-05-19 10:53  abcByme  阅读(20)  评论(1编辑  收藏  举报