Reputation: 515
I would like to find if my duration is > 0. I use MomentJs and Vue to get my duration using this code :
moment3: function (date) {
var now = moment();
var day = moment(date);
var duration = day.diff(now);
return parseInt(duration);
},
I get the duration correctly (2987546325 in example). But still this code not working.
<a v-if="event.time | moment3 > 0"> Do somethingHere </a>
Thank you for help.
Upvotes: 0
Views: 203
Reputation: 29092
I assume that you're trying to use moment3
as a Vue filter function.
There are two problems here:
v-if
expression. They're only available inside a {{ ... }}
or a v-bind
expression.> 0
isn't allowed even if you were in a {{ ... }}
or v-bind
.See https://v2.vuejs.org/v2/guide/filters.html
The |
character will just be interpreted as JavaScript's bitwise OR operator in this case.
You'd probably be better off just using a method instead. So define moment3
inside your component's methods
and then call it using v-if="moment3(event.time) > 0"
.
Upvotes: 2