Skip to content

身份证或手机号每 4 位分隔

js
{
  filters: {
    numberFormat(idNumber: string) {
      if (!idNumber) return '-';
      try {
        return idNumber.replace(/(\w{4})(?=\d)/g, (a, b) => {
          return b + ' ';
        });
      } catch (e) {
        return idNumber;
      }
    }
  }
}
{
  filters: {
    numberFormat(idNumber: string) {
      if (!idNumber) return '-';
      try {
        return idNumber.replace(/(\w{4})(?=\d)/g, (a, b) => {
          return b + ' ';
        });
      } catch (e) {
        return idNumber;
      }
    }
  }
}