【发布时间】:2019-12-31 01:04:30
【问题描述】:
我在 youtube 上关注 The Net Nijna 的教程。 我达到了第 27 个教程,在 ejs 中使用 partials。一切正常,直到我添加 ,一旦我添加了这个代码,我就会收到:
SyntaxError: Unexpected identifier in (file location) testapp\views\profile.ejs 同时编译 ejs
如果上述错误没有帮助,您可能想尝试 EJS-Lint:
https://github.com/RyanZim/EJS-Lint
或者,如果您打算创建一个异步函数,请将 async: true 作为选项传递。
在 new Function () ..... 等等等等......
如果我删除它,我的 ejs 一切正常。
<body>
<% include partials/nav.ejs %>
<h1>Welcome to the profile of <%= person %> !</h1>
<p><strong> Age: <%= data.age %></strong></p>
<p><strong> Job: <%= data.job %></strong></p>
<p><strong> Pet: <%= data.pet %></strong></p>
<h2>Hobbies</h2>
<ul>
<% data.hobbies.forEach(function(item){ %>
<li><%= item %></li>
<%});%>
</ul>
</body>
你能帮助一个学生吗?非常感谢!
【问题讨论】:
-
试试 或
-
试过第二个,没用,但你的第一个成功了!砰!非常感谢!
-
不客气