Lodash integration and filters for Vue
Download the project using your favourite package manager:
npm install @codekraft-studio/vue-lodash
yarn add @codekraft-studio/vue-lodash
Than load it inside your application main file:
import Vue from 'vue'
import VueLodash from '@codekraft-studio/vue-lodash'
Vue.use(VueLodash)
You can also customize the plugin installation using some options:
import Vue from 'vue'
import VueLodash from '@codekraft-studio/vue-lodash'
Vue.use(VueLodash, {
name: '_',
globalFilters: true
})
The plugin will install lodash globally in your Vue instance Vue._
, it will
be accessible from everywhere even inside your templates scope:
<li v-for="n in _.uniq([2, 4, 4, 6, 10, 1, 3, 1, 8, 6])">{{n}}</li>
Once you have installed the project and setup correctly you should be able to use almost all of the lodash methods as filters, for example:
<p>{{ description | capitalize }}</p>
You can also chain them to obtain more complex results:
<p>{{ description | capitalize | truncate }}</p>
yarn install
yarn run serve
yarn run build
yarn run test
yarn run lint
yarn run test:unit