Vue Currency Filter

5.2.0 · abandoned · verified Tue Apr 21

Vue Currency Filter is a lightweight library designed for formatting currency values within Vue 2 applications. It provides a flexible filter based on the principles of `accounting.js`, allowing developers to easily display monetary amounts with configurable symbols, separators, and decimal precision. The current stable version is 5.2.0. A key differentiator is its simplicity for Vue 2 projects needing quick currency formatting without complex component structures. However, it is critical to note that the project's GitHub repository was archived in May 2023, indicating that the library is no longer actively maintained. It is strictly for Vue 2, as Vue 3 removed the concept of filters.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates global registration of the currency filter with custom options and its usage in a Vue 2 template.

import Vue from 'vue'
import VueCurrencyFilter from 'vue-currency-filter'

// Global registration with custom options
Vue.use(VueCurrencyFilter, {
  symbol: '€',
  thousandsSeparator: '.', // Use dot for thousands
  fractionCount: 2,
  fractionSeparator: ',', // Use comma for decimals
  symbolPosition: 'front',
  symbolSpacing: true,
  avoidEmptyDecimals: '',
  useFractionalInput: false
})

new Vue({
  el: '#app',
  data: {
    amount: 12345.678,
    price: 99.5
  },
  template: `
    <div id="app">
      <p>Amount: {{ amount | currency }}</p>
      <p>Price: {{ price | currency("USD") }}</p>
      <p>Custom: {{ 123 | currency("£", 0) }}</p>
    </div>
  `
})

view raw JSON →