1.0.1 • Published 2 years ago

vue-currency-format v1.0.1

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

vue-currency-format

A Vue.js filter for formatting currency. This is super useful when working with applications that display pricing. It works well with Stripe currency formatting ie 1025 becomes £10.25

Installation

To install from npm

npm install vue-currency-format --save

Then include it in your main vue file.

import VueCurrencyFormat from 'vue-currency-format'
Vue.use(VueCurrencyFormat);

You can also include some global options.

import VueCurrencyFormat from 'vue-currency-format'

Vue.use(VueCurrencyFormat,{
    local: 'en',
    currency: 'GBP',
    hideSubUnits: false,
    subunitsValue: true
});

Then in your vue component you can use it like this. {{1025 | currency}} The result would be £10.25

or you can pass in options on an individual basis {{1025 | currency(locale,currency,hideSubUnits,subunitsValue)}}

Options

OptionDefault ValueDescription
LocaleenA BCP 47 language tag (for example en or de-DE). Default is undefined (use the runtime's default locale).
CurrencyGBPA ISO 4217 currency code (for example USD or EUR).
hideSubUnitsfalseWhether or not to show the sub units ie 1045 would be displayed as £10
subunitsValuetrueWhen set to true 1045 would be displayed as £1,025.00