2016-01-24 68 views
0

我嘗試使用下劃線:無法使用下劃線模塊parse.com

<% 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'); 

,並在應用程序。 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

我已經忘了在main.js補充一點:

app.locals.underscore = underscore; 

,我改名字「_」爲「下劃線」,得益於弗拉維奧Filho的。