@chatfoodio/vue currency

Vue currency filter

Version: 1.1.1 Updated: 08/18/2020

By: chatfood License: MIT

Downloads Last 30 Days: 5

Install

npm i @chatfoodio/vue-currency
yarn add @chatfoodio/vue-currency

Repository: https://github.com/chatfood/vue-currency

CDNs

bundle.run: https://bundle.run/@chatfoodio/vue-currency

jsDelivr: https://cdn.jsdelivr.net/npm/@chatfoodio/vue-currency

unpkg: https://unpkg.com/@chatfoodio/vue-currency

Vue currency

Developed and maintained by and for ChatFood 😉

Build Status

Usage

# install package
npm install @chatfoodio/vue-currency --save

Currency settings available (ISO_CODE): BRL, AED, USD, TRY

import Vue from "vue";
import ChatfoodCurrency from "@chatfood/vue-currency";

// Default Currency Settings
const settings = {
  symbol: "$",
  thousand: ",",
  precision: 2,
  decimal: ".",
  symbolFirst: true,
  symbolSeparator: " "
}

Vue.use(ChatfoodCurrency, settings); 
// or Vue.use(ChatfoodCurrency); 

// Set settings on the fly anywhere inside your components
this.$currency.setConfig("ISO_CODE");

// Set settings on the fly anywhere on your project
Vue.currency.setConfig("ISO_CODE");

// Get current settings
Vue.currency.getConfig();
<template>
  <!-- $ 12.43 -->
  <p>{{ 12.43 | currency }}</p>

  <!-- AED 12.43 -->
  <p>{{ 12.43 | currency({ symbol: "AED" }) }}</p>

  <!-- 12.43 -->
  <p>{{ 12.43 | currency({ symbol: "" }) }}</p>

  <!-- $ 12.4 -->
  <p>{{ 12.43 | currency({ precision: 1 }) }}</p>

  <!-- $ 12 -->
  <p>{{ 12.43 | currency({ precision: 0 }) }}</p>

  <!-- $ 3.412,43 -->
  <p>{{ 3412.43 | currency({ thousand: ".", decimal: "" }) }}</p>
</template>

Contribution

# install dependencies
npm install

# serve with hot reload at localhost:8080
npm run dev

# build your for production
npm run build

# run unit tests
npm run test

# publish library on NPM (Check your version first before publish.)
npm publish
Categories: Vue js
Tags: