How to format numbers in VueJS

How to format numbers in VueJS

If you ever wish to format your numbers in VueJs like adding thousands separators etc. today i will show you simple way to do it without installing any package.

JavaScript has a built-in function for this.

If you're sure the variable is always Number and never a “number String”, you can do:

{{ num.toLocaleString() }}

If you want to be safe, do:

{{ Number(num).toLocaleString() }}

source

- Last updated 1 year ago

Be the first to leave a comment.

You must login to leave a comment