vuejs / babel-plugin-transform-vue-jsx

babel plugin for vue 2.0 jsx
1.85k stars 132 forks source link

How to use the filter? #154

Open gooqiao opened 6 years ago

gooqiao commented 6 years ago
<div >
  {'2016-05-03' | customDateFilter("YYYY-MM-DD")}
</div>

customDateFilter is a filter,When I do, he does not work.

Is there any other way?

Shinigami92 commented 5 years ago

The only way I know is to rewrite it to something like this:

import customDateFilter from './customDateFilter'
// ...
<div >
  { customDateFilter('2016-05-03', 'YYYY-MM-DD') }
</div>

or with moment.js

import moment from 'moment'
// ...
const date // maybe can be undefined?!
<div >
  { date ? moment(date).format('YYYY-MM-DD') : '' }
</div>
guohuihot commented 4 years ago
this.$options.filters.customDateFilter('2016-05-03)