我不能得到我保存的数据从我的产品播种到商店正确
看起来像这个https://prnt.sc/t10v00
我想从我的数据图像和标题来到页面
在我的终端上写着//// Handlebars:解析属性“title”的访问被拒绝,因为它不是其父级的“自己的属性”
{{# each products}}
<div class="row">
{{# each this}}
<div class="col-sm-6 col-md-4">
<div class="thumbnail">
<img src="{{this.imagePath}}" alt="..." class = "img-responsive">
<div class="caption">
<h3 align="center">{{this.title}}</h3>
<p class="description">{{this.description}}</p>
<div class="clearfix">
<div class="price pull-left">€{{this.price}}<ahref="#" style="float:right"class="btn btn-primary pull-right" role="button">Add cart</a> </div>
</div>
</div>
</div>
{{/each}}
</div>
{{/each}}
index.js
var express = require('express');
var router = express.Router();
var Product = require('../models/product');
/* GET home page. */
router.get('/', function(req, res, next) {
Product.find(function(err, docs) {
var productChunks = [];
var chunkSize = 3;
for (var i = 0; i < docs.length; i += chunkSize) {
productChunks.push(docs.slice(i, i + chunkSize));
}
res.render('shop/index', { title: 'Shopping Cart', products: productChunks });
});
});
module.exports = router;
有谁能帮我吗?
4条答案
按热度按时间x6yk4ghg1#
使用这个版本。它起作用了。它为较新的版本提供了相同的输出。
5cg8jx4n2#
遵循下面给出的语法:
k97glaaz3#
这段代码适合我:
g2ieeal74#