YntaxError:无效或意外的令牌
在我的EJS文件中:
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title>To do List</title>
</head>
<body>
<% if (kindOfDay === “Saturday” || kindOfDay === “Sunday”) { %>
<h1 style="color: green"><%= kindOfDay %> List </h1>
<% } else { %>
<h1 style="color: blue"><%= kindOfDay %> List </h1>
<% } %>
</body>
</html>
当代码为:
<h1>it's a<%= kindOfDay %> List </h1>
有效时,但现在显示:
syntaxerror:/users/annezhang/desktop/test/views/list.ejs in comply ejs
in/users/annezhang/desktop/test/list.ejs中的无效或意外令牌
如果以上错误无用,则可能需要尝试EJS-lint: https://github.com/ryanzim/ejs-lint 或者,如果您打算创建异步函数,请将
async:true
作为选项传递。 在新功能() 在template.compile(/users/annezhang/desktop/test/node_modules/ejs/lib/ejs.js:js:662:12) 在object.compile(/users/annezhang/desktop/test/node_modules/ejs/lib/ejs.js:js:396:16) 在handlecache(/users/annezhang/desktop/test/node_modules/ejs/lib/ejs.s.js:233:18) 在tryhandlecache(/users/annezhang/desktop/test/node_modules/ejs/lib/ejs.js:js:272:16) at View.exports.renderfile [AS Engine](/Users/annezhang/desktop/test/node_modules/ejs/lib/ejs.js.js:489:10) at View.render(/Users/annezhang/desktop/test/node_modules/express/lib/view.js:135:8) 在TryRender(/Users/annezhang/desktop/test/node_modules/express/lib/application.js:640:10) at function.render(/users/annezhang/desktop/test/node_modules/express/lib/application.js:592:3) 在serverresponse.render(/Users/annezhang/desktop/test/node_modules/express/lib/response.js:1017:7)
我不确定问题是什么。
In my EJS file:
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title>To do List</title>
</head>
<body>
<% if (kindOfDay === “Saturday” || kindOfDay === “Sunday”) { %>
<h1 style="color: green"><%= kindOfDay %> List </h1>
<% } else { %>
<h1 style="color: blue"><%= kindOfDay %> List </h1>
<% } %>
</body>
</html>
When the code is:
<h1>it's a<%= kindOfDay %> List </h1>
it works, but now it shows:
SyntaxError: Invalid or unexpected token in /Users/annezhang/Desktop/test/views/list.ejs while compiling ejs
If the above error is not helpful, you may want to try EJS-Lint:
https://github.com/RyanZim/EJS-Lint
Or, if you meant to create an async function, passasync: true
as an option.
at new Function ()
at Template.compile (/Users/annezhang/Desktop/test/node_modules/ejs/lib/ejs.js:662:12)
at Object.compile (/Users/annezhang/Desktop/test/node_modules/ejs/lib/ejs.js:396:16)
at handleCache (/Users/annezhang/Desktop/test/node_modules/ejs/lib/ejs.js:233:18)
at tryHandleCache (/Users/annezhang/Desktop/test/node_modules/ejs/lib/ejs.js:272:16)
at View.exports.renderFile [as engine] (/Users/annezhang/Desktop/test/node_modules/ejs/lib/ejs.js:489:10)
at View.render (/Users/annezhang/Desktop/test/node_modules/express/lib/view.js:135:8)
at tryRender (/Users/annezhang/Desktop/test/node_modules/express/lib/application.js:640:10)
at Function.render (/Users/annezhang/Desktop/test/node_modules/express/lib/application.js:592:3)
at ServerResponse.render (/Users/annezhang/Desktop/test/node_modules/express/lib/response.js:1017:7)
I’m not sure what is the problem.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论