Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
Simple Developer
Simple Developer
I'll demonstrate configuration to use my 'formatDate' Vue.js filter in my NuxtJS project.
I’ll demonstrate configuration to use my ‘formatDate’ Vue.js filter in my NuxtJS project.
Because I’ll use Day.js to format date, I need to install package first.
npm install dayjs --save
filters.js
file to /plugins
folderAll of my Vue.js filters are managed by filters.js
file.
Add your filters in this file.
import Vue from 'vue' import _ from 'lodash' import dayjs from 'dayjs' Vue.filter('formatDate', (value, format) => { return dayjs(value).format(format) }) Vue.filter('startCase', (str) => { if (!str) return '' str = _.startCase(str.toString()) return str })
filters.js
file to nuxt.config.js
fileexport default { // Plugins to run before rendering page: https://go.nuxtjs.dev/config-plugins plugins: [ "~plugins/filters.js" ], }
<div>{{ article.createdAt | formatDate('DD MMM, YYYY') }}</div>