πŸ”Ÿ Use Numeral.js as a Vue filter to formatting numbers.
Switch branches/tags
Clone or download

README.md

vue-numerals

Build Status

Use the power of Numerals.js to properly format numbers inside your Vue components!

Requirements

  • Vue 2
  • Node.js 8+

Installation

In the browser

<script src="https://unpkg.com/vue-numerals/dist/vue-numerals.min.js" />

With Node.js

$ yarn add vue-numerals
import Vue from 'vue';
import VueNumerals from 'vue-numerals';

Vue.use(VueNumerals);

// with options
Vue.use(VueNumerals, {
  locale: 'fr'
});

Usage

Inside your component:

<template>
  <div>
    <!-- With french locale, it will display: `12 345` -->
    <p>{{ count | numeralFormat }}</p>
    
    <!-- With french locale, it will display: `12 345 €` --> 
    <p>{{ count | numeralFormat('0,0[.]00 $') }}</p>
  </div>
</template>

<script>
export default {
  data: () => ({ count: 12345 }),
}
</script>

License

MIT