0

How does one access the filters defined on a Vue component (globally or locally) from within the render function? Neither the documentation nor a dump of this offer much help. The first trivial answer is to put the filter functions in an export, but that defeats the purpose of the Vue filter functionality. The second trivial answer is to import Vue, but that defeats the purpose of asking this in the first place.

The code in question is in a Nuxt context. I defined the filters in a file ~/plugin/filters.js, and updated the plugins configuration point in nuxt.config.js to run ~/plugin/filters.

this.$options does not have a filters property (although its prototype does).

I'm assuming functional must be false, but an answer that works for functional components is acceptable.

3
  • Does this answer your question? In Vue JS, call a filter from a method inside the vue instance Commented May 3, 2020 at 21:37
  • it doesn't. this.$options doesn't have a filters property, and import Vue defeats the purpose of this question. Commented May 4, 2020 at 1:34
  • just a suggestion, whatever you are trying to do with filters, i recommend switching to methods instead, filters are deprecated in Vue3 Commented May 4, 2020 at 10:09

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.