Vue 过滤方法 数字补零
Vue.filter('allFilter', (value = '') => {if (!['[object Number]', '[object String]'].includes(Object.prototype.toString.call(value))) {return value}let num = value.toString().replace...
·
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
})
更多推荐
已为社区贡献12条内容
所有评论(0)