无法在parse.com中使用下划线模块

时间:2016-01-24 14:49:01

标签: parse-platform

我尝试使用下划线:

 <% if (!_.isEmpty(comments)) { %>
  <h2>All Comments</h2>
  <% comments.forEach(function(comment) { %>
    <% include ../admin/_comment %>
  <% }) %>
<% } else { %>
  <p>No comments yet.</p>
<% } %>

我在控制器中添加(在此处注释)以下代码:

var _ = require('cloud/libs/underscore-min');

并在app.js

var _ = require('cloud/libs/underscore-min');

但是我收到了这个错误:

_ is not defined
at eval (eval at <anonymous> (ejs.js:256:12), <anonymous>:31:214)
at ejs.js:261:15
at Object.exports.render (ejs.js:299:13)
at View.exports.renderFile [as engine] (ejs.js:325:22)
at View.render (express_view.js:77:8)
at Function.app.render (express_application.js:516:10)
at res.render (express_response.js:763:7)
at e.<anonymous> (controllers/gift.js:9:17)
at e.i (Parse.js:14:27703)
at e.a.value (Parse.js:14:27063)

你能帮助我吗?

谢谢!

1 个答案:

答案 0 :(得分:0)

我忘记在main.js中添加它:

app.locals.underscore = underscore;

我将名称“_”更改为“下划线”,感谢Flavio Filho。