vue-money-format is a lightweight Vue component designed for displaying localized currency values, leveraging the browser's native `Intl.NumberFormat` API. Currently at version 1.2.4, its release cadence appears to be infrequent, with the last known activity around 2020. A key differentiator is its flexibility in handling currency values, supporting both standard super-unit representations (e.g., $100.00) and subunit-based integer storage (e.g., 10000 cents), which aligns with patterns found in libraries like Ruby Money gems to avoid floating-point inaccuracies. It offers configurable localization via BCP 47 language tags and currency symbols via ISO 4217 codes, and includes options to suppress subunit display with automatic rounding. The component boasts no external dependencies beyond Vue itself, making it a lean solution focused solely on currency presentation.
npm install vue-money-formatVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates `vue-money-format`'s core features: subunit/full unit input, locale/currency codes, hiding subunits with rounding, custom `subunits-to-units` conversion, and interactive input with `v-model.number`.
Ensure you are using Vue 2, or if using Vue 3, consider a compatibility wrapper or an alternative component specifically designed for Vue 3. Check for Vue 3 forks or updated versions.
If supporting older browsers or specific environments, ensure `Intl.NumberFormat` polyfills are included. For Node.js environments, ensure full ICU data is available if performing server-side rendering.
Use either `subunits-value` (for standard subunit conversion like cents) or `subunits-to-units` (for custom, non-standard minor unit conversion). Do not set both if you expect `subunits-value` to take effect when `subunits-to-units` is present.
Be aware of the rounding behavior when using `hide-subunits`. If exact (even if hidden) fractional precision is paramount for downstream logic, avoid `hide-subunits` or perform rounding logic externally if it conflicts with expectations.
Ensure `import MoneyFormat from 'vue-money-format';` is present in your script, and the component is registered via `components: { 'money-format': MoneyFormat }`.For older browsers, include an `Intl.NumberFormat` polyfill. For Node.js, ensure full ICU data is enabled (e.g., by setting the `NODE_ICU_DATA` environment variable or using the `full-icu` package).
Ensure the `value` prop is always passed as a number. Use type coercion like `Number(myStringValue)`, `parseInt(myStringValue)`, `parseFloat(myStringValue)`, or Vue's `v-model.number` directive on input elements.