上这是我的架构查询数据并显示一个HTML页面
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我打电话这种说法其中路线是我的变量在index.js中调用欢迎程序 app.get('/ welcome',routes.welcome);
我的模式也写在index.js中。我想要做的是在名为“welcome.html”的html页面中显示所有产品的名称和说明。
任何人都可以告诉我,我应该在我的html页面上写什么来做到这一点。
内容的HTML渲染器是您使用? – alandarev
app.set('views',path.join(__ dirname,'views')); app.engine('html',require('ejs')。renderFile); app.set('view engine','html');这是我在我的app.js中写的。 – user3789868
无处不在,我可以找到像发送数据玉,然后显示在玉,但不是在HTML? – user3789868