N
N
newitem2021-09-22 12:35:35
Vue.js
newitem, 2021-09-22 12:35:35

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

1 answer(s)
0
0xD34F, 2021-09-22
@newitem

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 question

Ask a Question

731 491 924 answers to any question