Last active
March 19, 2019 21:28
-
-
Save xesjkeee/65e726519bd170744951795a8efeb36c to your computer and use it in GitHub Desktop.
Price Format
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Vue.filter('priceFormat', function (val) { | |
if (typeof val !== 'number' && typeof val !== 'string') return val | |
if (typeof val === 'string') val = parseInt(val) | |
const res = Math.round(val * 100) / 100 | |
return res.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ' ') | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment