vue-admin icon indicating copy to clipboard operation
vue-admin copied to clipboard

How to add filters?

Open rojermaharjan opened this issue 8 years ago • 3 comments

Can you please give an example on how to use filters?

rojermaharjan avatar Oct 15 '17 08:10 rojermaharjan

https://011.vuejs.org/api/filters.html

{{count}} {{count | pluralize item}}

acampagnaro avatar Oct 15 '17 12:10 acampagnaro

What I meant to say was, how do I add filters globally and access it by using the index.js file that is included in this project inside filters folder.

rojermaharjan avatar Oct 16 '17 03:10 rojermaharjan

In filters/index.js you do

import Foo from './foo'

export const foo = Foo

And in filters/foo.js you do:

export default (value) => {
  return 'foo' + value 
}

Now you can use {{ 'bar' | foo }} and result should be foobar

bytebrain avatar Dec 18 '17 13:12 bytebrain