Vue.filter('allFilter', (value = '') => {
  if (!['[object Number]', '[object String]'].includes(Object.prototype.toString.call(value))) {
    return value
  }
  let num = value.toString().replace(/^(\d+)(\.\d+)?$/g, (big, ...args) => {
    let [a, b] = args
    if (!b) b = '.'
    while (b.length <= 2) {
      b += '0'
    }
    return a + b
  })
  return num
})

 

Logo

前往低代码交流专区

更多推荐