currency

Formats a string number to a currency number using the browser's Intl objectopen in new window. Currency codes are based on ISO 4217open in new window.

Installation

Global install:

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

Vue.filter('currency', currency);

Local install:

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

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

Example

Custom Locale

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

Custom Default Formatting

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

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

const usd = str => currency(str, 'USD');
const euro = str => currency(str, 'EUR', 'de-DE');

Vue.filter('usd', usd);
Vue.filter('euro', euro);