Im creating a website where I show today's date with ejs, formatted with momentjs. Here is my code:
<h1>Eduardo's Contact List</h1>
<% var a = moment().format("MMMM Do YYYY"); %>
<p>Today is <%= a %></p>
An error appears saying that moment is not defined. I run into this problem regardless if I call the script in the head or right before the closing body tag.
However, when I run the program without calling the functions, I can use moment in the console, meaning that I am calling the moment script correctly.
Are momentjs and embeddedjs incompatible? What am I doing wrong?
答案 0 :(得分:0)
非常简单的解决方案:
我将变量放在js脚本中:
print RETCODE_THING_2_FAILED
确保在调用momentjs脚本后调用它。
不需要使用ejs。