Skip to content

Instantly share code, notes, and snippets.

@danielturus
Created February 8, 2019 13:07
Show Gist options
  • Save danielturus/e84579a11a74d9a67fef915101fd70d6 to your computer and use it in GitHub Desktop.
Save danielturus/e84579a11a74d9a67fef915101fd70d6 to your computer and use it in GitHub Desktop.
Vuejs filters - Register multiple filters globally in VueJS (NuxtJS)
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