How do i add global filters to Quasar?
-
I cant seem to figure out how to add filters globally . Should i make a folder for global filters and then export the filter file but where do i refer it there isn’t any option for filters in quasar.config.js.
-
You should use
vue mixins
https://vuejs.org/v2/guide/mixins.html
-
Any specific reasons for favouring mixins over filters ?
-
You define filters in the mixin. Then the mixin globally or per component that requires it.
-
You can also use a boot file to declare global
filter
:// src/boot/filters.js export default ({ Vue}) => { Vue.filter('YourAwesomeFilter', function (value) { return ... }) }
Don’t forget to reference your file in
quasar.conf.js
-