js银行卡号脱敏

uniapp yekong

保留前三位后三位


let accountNo = '123456789123456789'
accountNo.substr(0,3) + '******' + accountNo.substr(accountNo.length - 3)

保留后四位


let accountNo = '123456789123456789'
'******' + accountNo.substr(accountNo.length - 4)

vue


<p>{{ $t('finance.zh') }}:{{ item.account|filterscard(type) }}</p>

js过滤器


  filters: {
    filterscard: function (id, type) {
      if (type == 1) {
        return '****************' + id.substr(id.length - 4)
      } else {
        return id
      }
    }
  },
喜欢