Vue.js和vue-moment:“无法解析过滤器:时刻” [英] Vue.js and vue-moment: "Failed to resolve filter: moment"
问题描述
尝试使用 vue-moment 。文档中最简单的示例不起作用: https://jsfiddle.net/rjcpz9wt/
Trying to use vue-moment. The simplest possible example from the documentation doesn't work: https://jsfiddle.net/rjcpz9wt/
<span>{{ new Date() | moment "dddd, MMMM Do YYYY" }}</span>
给予:
[Vue warn]: Failed to resolve filter: moment
发生了什么事?
推荐答案
vue-moment
已损坏。
只需将其添加为< script>
标记即可使用它。目前只有使用webpack或browserify编译它才有效,请参阅问题更新。
You can't use it by just adding it as a <script>
tag. Currently it only works if you use compile it with webpack or browserify, see this issue for updates.
它曾经在原始版本上运行良好:
https://github.com/brockpetrie/vue-moment/tree/fd6fcb901415c1df4c5abb81870d49b346d3732f
It used to work well on the original version: https://github.com/brockpetrie/vue-moment/tree/fd6fcb901415c1df4c5abb81870d49b346d3732f
查看原文在这里工作的版本: https://jsfiddle.net/gerardog/vaw33sn2/
See the original version working here: https://jsfiddle.net/gerardog/vaw33sn2/
另外,在Fiddle上不要链接到 https://raw.github.com/中的文件,使用这个漂亮的
解决方法
Also, on Fiddle dont link to files in https://raw.github.com/ , use this nice workaround
这篇关于Vue.js和vue-moment:“无法解析过滤器:时刻”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!