How can I comment the EJS code (JS node) without getting an error(如何才能在不出错的情况下注释ejs代码(js节点)?)
本文介绍了如何才能在不出错的情况下注释ejs代码(js节点)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在ejs文件中有此代码:
<table>
<% for(var i=0; i < data.length; i++) { %>
<tr>
<td><%= data[i].id %></td>
<td><%= data[i].name %></td>
</tr>
<% } %>
</table>
当我这样评论它时,
<!-- <table> -->
<!-- <% for(var i=0; i < data.length; i++) { %> -->
<!-- <tr> -->
<!-- <td><%= data[i].id %></td> -->
<!-- <td><%= data[i].name %></td> -->
<!-- </tr> -->
<!-- <% } %> -->
<!-- </table> -->
我在第2行仍然有一个错误。以下是错误堆栈:
ReferenceError: c:Users oumiDesktopworkspaceseclipseToDoListviewsx.ejs:2
1| <!-- <table> -->
>> 2| <!-- <% for(var i=0; i < data.length; i++) { %> -->
3| <!-- <tr> -->
4| <!-- <td><%= data[i].id %></td> -->
5| <!-- <td><%= data[i].name %></td> -->
data is not defined
at eval (eval at <anonymous> (c:Users oumiDesktopworkspaceseclipseToDoList
ode_modulesejslibejs.js:455:12), <anonymous>:11:25)
at c:Users oumiDesktopworkspaceseclipseToDoList
ode_modulesejslibejs.js:482:14
at View.exports.renderFile [as engine] (c:Users oumiDesktopworkspaceseclipseToDoList
ode_modulesejslibejs.js:348:31)
at View.render (c:Users oumiDesktopworkspaceseclipseToDoList
ode_modulesexpresslibview.js:93:8)
at EventEmitter.app.render (c:Users oumiDesktopworkspaceseclipseToDoList
ode_modulesexpresslibapplication.js:566:10)
at ServerResponse.res.render (c:Users oumiDesktopworkspaceseclipseToDoList
ode_modulesexpresslib
esponse.js:938:7)
at c:Users oumiDesktopworkspaceseclipseToDoList odoList.js:13:6
at Layer.handle [as handle_request] (c:Users oumiDesktopworkspaceseclipseToDoList
ode_modulesexpresslib
outerlayer.js:82:5)
at next (c:Users oumiDesktopworkspaceseclipseToDoList
ode_modulesexpresslib
outer
oute.js:110:13)
at Route.dispatch (c:Users oumiDesktopworkspaceseclipseToDoList
ode_modulesexpresslib
outer
oute.js:91:3)
如何注释此代码?
推荐答案
有两种解决方案:
<%# comment %>
(来自documentation)<%/* comment */%>
(也可以,但是很难看,使用起来不舒服)
除了突出显示IDE中的语法外,我看不出这些示例之间有什么不同(使用BracketsIDE的示例)。
这篇关于如何才能在不出错的情况下注释ejs代码(js节点)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
沃梦达教程
本文标题为:如何才能在不出错的情况下注释ejs代码(js节点)?


猜你喜欢
- Css:将嵌套元素定位在父元素边界之外一点 2022-09-07
- addEventListener 在 IE 11 中不起作用 2022-01-01
- 400或500级别的HTTP响应 2022-01-01
- 失败的 Canvas 360 jquery 插件 2022-01-01
- 如何使用 JSON 格式的 jQuery AJAX 从 .cfm 页面输出查 2022-01-01
- CSS媒体查询(最大高度)不起作用,但为什么? 2022-01-01
- Fetch API 如何获取响应体? 2022-01-01
- Quasar 2+Apollo:错误:找不到ID为默认的Apollo客户端。如果您在组件设置之外,请使用ProvideApolloClient() 2022-01-01
- 使用RSelum从网站(报纸档案)中抓取多个网页 2022-09-06
- Flexslider 箭头未正确显示 2022-01-01