Created
February 8, 2019 13:07
-
-
Save danielturus/e84579a11a74d9a67fef915101fd70d6 to your computer and use it in GitHub Desktop.
Vuejs filters - Register multiple filters globally in VueJS (NuxtJS)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Vue from 'vue' | |
export function formatDateRo(date) { | |
return new Date(date).toLocaleDateString('ro-RO') | |
} | |
export function roundToTwo(num) { | |
return +(Math.round(num + 'e+2') + 'e-2') | |
} | |
const filters = { | |
roundToTwo, | |
formatDateRo | |
} | |
Object.keys(filters).forEach(key => { | |
Vue.filter(key, filters[key]) | |
}) | |
export default filters |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment