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

后端 未结 4 1293
时光说笑
时光说笑 2021-02-10 09:06

Trying to use vue-moment. The simplest possible example from the documentation doesn\'t work: https://jsfiddle.net/rjcpz9wt/

{{ new Date() | moment \         


        
4条回答
  •  既然无缘
    2021-02-10 09:28

    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

    https://jsfiddle.net/rdffywc7/

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

    and then in the doc body

    {{ date }}
    

提交回复
热议问题