EJS.JS ReferenceError: title not defined

99封情书 提交于 2019-12-04 17:19:15

Seems like the error is actually in the header file which proprely contains something like:

<%= title %>

I think changing changing it to the following will work:

<%= (typeof title != "undefined" ? title : "") %>

You need to give your title a value, if not already done. If it is done, then @andlrc answer is correct, but you still want to figure out why it is throwing an error. If not, it is bad practice.

In your server define a variable names title and give it a string. Then expose is to your view.

In this answer you find an example.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!