SyntaxError:意外的令牌' for'在i:\完整的Web开发课程\ ejs \ to do list \ views \ views \ list.ejs时
我一直在尝试使用EJS创建此操作列表,并将其应用于HTML。 但是没有得到结果。
代码段:
<ul>
<li>Food Items</li>
<li>Play Cricket</li>
<li>Learn To code</li>
<li>Apply for jobs</li>
<li>Play game of Chess</li>
<% for(int i = 0;i<new_item.length;i++) %>
<% { %>
<li> <%= new_item %> </li>
<% } %>
</ul>
错误获取:
SyntaxError: Unexpected identifier in I:\Complete Web Development Course\EJS\To Do List\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, pass `async: true` as an option.
at new Function (<anonymous>)
at Template.compile (I:\Complete Web Development Course\EJS\To Do List\node_modules\ejs\lib\ejs.js:673:12)
at Object.compile (I:\Complete Web Development Course\EJS\To Do List\node_modules\ejs\lib\ejs.js:398:16)
at handleCache (I:\Complete Web Development Course\EJS\To Do List\node_modules\ejs\lib\ejs.js:235:18)
at tryHandleCache (I:\Complete Web Development Course\EJS\To Do List\node_modules\ejs\lib\ejs.js:274:16)
at View.exports.renderFile [as engine] (I:\Complete Web Development Course\EJS\To Do List\node_modules\ejs\lib\ejs.js:491:10)
at View.render (I:\Complete Web Development Course\EJS\To Do List\node_modules\express\lib\view.js:135:8)
at tryRender (I:\Complete Web Development Course\EJS\To Do List\node_modules\express\lib\application.js:657:10)
at Function.render (I:\Complete Web Development Course\EJS\To Do List\node_modules\express\lib\application.js:609:3)
at ServerResponse.render (I:\Complete Web Development Course\EJS\To Do List\node_modules\express\lib\response.js:1039:7)
I have been trying this create a to do list using ejs and applying it in html.
But Failing to get the result.
CODE Snippet:
<ul>
<li>Food Items</li>
<li>Play Cricket</li>
<li>Learn To code</li>
<li>Apply for jobs</li>
<li>Play game of Chess</li>
<% for(int i = 0;i<new_item.length;i++) %>
<% { %>
<li> <%= new_item %> </li>
<% } %>
</ul>
Error Getting:
SyntaxError: Unexpected identifier in I:\Complete Web Development Course\EJS\To Do List\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, pass `async: true` as an option.
at new Function (<anonymous>)
at Template.compile (I:\Complete Web Development Course\EJS\To Do List\node_modules\ejs\lib\ejs.js:673:12)
at Object.compile (I:\Complete Web Development Course\EJS\To Do List\node_modules\ejs\lib\ejs.js:398:16)
at handleCache (I:\Complete Web Development Course\EJS\To Do List\node_modules\ejs\lib\ejs.js:235:18)
at tryHandleCache (I:\Complete Web Development Course\EJS\To Do List\node_modules\ejs\lib\ejs.js:274:16)
at View.exports.renderFile [as engine] (I:\Complete Web Development Course\EJS\To Do List\node_modules\ejs\lib\ejs.js:491:10)
at View.render (I:\Complete Web Development Course\EJS\To Do List\node_modules\express\lib\view.js:135:8)
at tryRender (I:\Complete Web Development Course\EJS\To Do List\node_modules\express\lib\application.js:657:10)
at Function.render (I:\Complete Web Development Course\EJS\To Do List\node_modules\express\lib\application.js:609:3)
at ServerResponse.render (I:\Complete Web Development Course\EJS\To Do List\node_modules\express\lib\response.js:1039:7)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
int
不是EJS中的有效类型声明,因此您应该使用Let
或var
而不是。int
is not a valid type declaration in ejs so you should uselet
orvar
instead.