【发布时间】:2014-08-30 04:07:21
【问题描述】:
这是我的架构
var productSchema = new mongoose.Schema({
name: String,
description: String
});
var Product = mongoose.model('Product', productSchema);
在我使用的 index.js 中
exports.welcome = function(req,res) {
Product.find({},{},function(err,docs) {
res.render('welcome', {
"productlist" : docs
});
});
};
在我的 app.js 中,我调用了这个语句,其中 routes 是我在 index.js 中调用 Welcome 的变量 app.get('/welcome',routes.welcome);
我的架构也是用 index.js 编写的。我想要做的是在名为“welcome.html”的 html 页面中显示所有产品及其名称和描述。
谁能告诉我我应该在我的 html 页面中写什么来做到这一点。
【问题讨论】:
-
你用的是什么 html 渲染器?
-
app.set('views', path.join(__dirname, 'views')); app.engine('html', require('ejs').renderFile); app.set('视图引擎', 'html');这是我在 app.js 中写的。
-
我能找到的任何地方都像将数据发送到翡翠然后显示在翡翠中但不是在html中?