EJS.JS ReferenceError:标题未定义 [英] EJS.JS ReferenceError: title not defined

查看:187
本文介绍了EJS.JS ReferenceError:标题未定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在快速脚本中遇到问题.我正在调用另一个视图成功的函数.在这个项目中,我将angular,node,express和ejs用作视图引擎.渲染视图时,很不幸收到以下ejs错误:

I am having an issue with a script in express. I am calling a function that renders a view, on the success of another function. In this project I am utilizing angular, node, express, and ejs as view engine. When I render the view, I unfortunately receive an ejs error of the following:

ReferenceError: /Users/emilywfrancis/Desktop/nodejs-angularjs-sequelizejs/views/about.ejs:5

3| <html ng-app="app">

4| <meta charset="utf-8">

5| <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/font-awesome/3.1.0/css/font-awesome.min.css" />

6| <% include header %>

7| <% include navbar %> 

8| <body>
  title is not defined

这是代码:

exports.verifyusers= function(req, res) {
models.user.find({
where: {
  email: req.body.email,
  password: req.body.password
}
 }).then(function(res, user) {
    if(user == "user.name") { //if user exists in database
        res.render('/about')
    };
 });
};

推荐答案

似乎错误实际上在头文件中,而头文件中通常包含以下内容:

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 : "") %>

这篇关于EJS.JS ReferenceError:标题未定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆