【发布时间】:2020-07-07 01:42:49
【问题描述】:
我是 Web 开发的新手,正在尝试学习如何使用 javascript 和 .pug。我已经用图像文件设置了 var camgrounds
router.get('/campgrounds', function (req, res) {
var campgrounds = [
{
title: "Paynetwon Campground",
image: img(src ="https://cdn.pixabay.com/photo/2020/06/14/17/57/mountains-5298769_960_720.jpg")
}];
res.render('campground', {
campgrounds: campgrounds
});
});
当我尝试去露营地渲染页面时,我收到错误消息 “img is not defined”
在我的 camground.pug 上,我写道:
doctype html
each camping in campgrounds
ul
li= camping.title
li = camping.image
有人可以帮忙解决这个错误代码吗?
【问题讨论】:
标签: javascript node.js express pug