Answer the question
In order to leave comments, you need to log in
How to use global filter in methods?
Hello.
I have a filter which is registered globally.
When working, I use the standard logic {{ text | nameFilter}}
I want to use in methods, but I can't because it is not local.
I don't understand how to use it
Answer the question
In order to leave comments, you need to log in
And do you really need it? Maybe it shouldn't be a filter then? Think about it.
Global filters are in Vue.options.filters
. Respectively:
const filteredValue = Vue.options.filters.someFilter(value);
// или, если вспомнить, что компоненты являются экземплярами Vue
const filteredValue = this.constructor.options.filters.someFilter(value);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question