Vue Currency Filter
Lightweight vue currency filter based on accounting.js.
Download
Sample Usage
Step by step to using vue-currency-filter
:
Import in main.js
Use Plugins
Add Global Configuration
Use in View
Usage in Nuxt.js
Add vue-currency-filter/nuxt
to modules section of nuxt.config.js
Usage without NPM
Add script dependencies
Use filters in global
See https://codepen.io/mazipan/pen/YdmNMy for code sample.
Add Configuration In Specific Place
Now configurations is also available as Object, thanks to sunhengzhe in PR #25:
Available Options
Update Global Configs
Since global config only can be setted from Vue.use(VueCurrencyFilter, configs)
, but sometimes we need to update this global configs on runtime process.
from v3.1.0 we intoduce prototype method that can be update this global configs. You can use anywhere in your components like this code below:
But please be aware, this method is only update global configs without trigger to re-run filter function. So maybe you will face not sync data from your configs and your view. You need to update some value to trigger this new configs applied.
How to test in Unit Test
Using @vue/test-utils
we can create test for any Vue Plugins, like:
See sample test here: https://codesandbox.io/s/6xk1mv694n