A filter is just a function. It takes some data (passed in as an argument to the filter function), and performs some simple operations on that data. The result of the operations performed is returned from the filter function and displayed in the appropriate place in the app. It's important to note that filters do not affect the underlying data; they only affect the way that data is displayed on the screen.
Just like components, filters too can be registered as either global or local. The syntax for registering a global filter is as follows:
Vue.filter('justAnotherFilter', function(someData1, someData2, someDataN) { // the filter function definition goes here (it takes N number of arguments) });
Besides global registration, we can also register a filter locally, like this:
filters: { justAnotherFilter(someData1, someData2, someDataN) { // the filter function is defined here... } }
As we can see here, in case of local registration, filters are added as an option to a Vue...