Ruby Ruby - 1 year ago 733
Javascript Question

Vue.js and vue-moment: "Failed to resolve filter: moment"

Trying to use vue-moment. The simplest possible example from the documentation doesn't work:

<span>{{ new Date() | moment "dddd, MMMM Do YYYY" }}</span>


[Vue warn]: Failed to resolve filter: moment

What is going on?

Answer Source

I wouldn't suggest doing it the way you are, you should create the date variable in the javascript code and just access the variable in your Vue. Here is a fiddle showing what I mean

var app = new Vue({
  el: document.body,
  data: {
    date: moment().format("dddd, MMMM Do YYYY")

and then in the doc body

<span>{{ date }}</span>
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download