JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1438
  • Score
    100M100P100Q114348F
  • License MIT

Package Exports

  • vue-money-format

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (vue-money-format) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

vue-money-format

A Vue component that formats currency.

This uses Intl.NumberFormat: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat

Description

This is a lightweight display component for localized currency display. It has no dependencies. It supports both float and integer input, and can adjust for values stored as decimal-based subunits, such as cents, dirham, groszy, etc. Storing currency values in terms of the subunit allows you to store integers, rather than floating numbers, which ensures accuracy.

Many libraries, such as the Ruby Money and Money-Rails gems, expect monetary values to be stored as integers.

Features

  • Supports currency value in super unit or subunit values (input can be $100.00 or 10000 cents)
  • Supports localized formatting keyed by BCP 47 language tags
  • Suuports currency symbols keyed by ISO 4217 currency codes
  • Supports suppression of the subunit display (you can display $100.65 or $101). When the subunit display is suppressed, the value will be rounded prior to display.

Installation

yarn add vue-money-format

Usage

<template>
  <div>
    <money-format :value="cost" 
      :locale='en' 
      :currency-code='USD' 
      :subunit-value=true 
      :hide-subunits=true>
    </money-format>
  </div>
</template>

<script>
  import {MoneyFormat} from 'v-money-format'

  export default {
    components: {
    money-format: MoneyFormat
    },

    data () {
      return {
        cost: 12345
        }
      }
    }
  }
</script>

Input options

  • value: Numerical input (only required input)
  • locale: Language and country information, such as 'en' or 'en-US'. Defaults to 'en'
  • currency-code: ISO 4217 3-character alpha code in upper or lower case. Defaults to 'USD'
  • subunits-value: Set to true if value is denominated in subunits, such as cents. Defaults to false
  • hide-subunits: Do not display the subunits. Defaults to false

References

License

Copyright (c) 2018 Ed Gomolka. Released under the MIT license. MIT