number

Formats a string number to a user friendly number using the browser's Intl objectopen in new window. Note that the format will default to the user's browser locale settings based on navigator.languageopen in new window.

Installation

Global install:

import Vue from 'vue';
import { number } from 'vuetensils/src/filters';

Vue.filter('number', number);

Local install:

<script>
  import { number } from 'vuetensils/src/filters';

  export default {
    filters: {
      number,
    },
  };
</script>

Example

Custom Locale

You can specify the locale formatting by passing the filter your target ISO Language Codeopen in new window.

Custom Default Locale

You can specify your own default locale formatting by extending the filter and providing your target ISO Language Codeopen in new window.

import Vue from 'vue';
import { number } from 'vuetensils/src/filters';

const customNumber = str => number(str, 'de-DE');

Vue.filter('number', customNumber);