Javascript 在Pug/Jade模板引擎中显示图像
我正在尝试显示get Http方法(“/campgrounds”)的对象中的图像。使用CampGrands数组的Get Http方法有3个具有2个属性的对象 如何在主页中显示图像链接Javascript 在Pug/Jade模板引擎中显示图像,javascript,express,pug,template-engine,Javascript,Express,Pug,Template Engine,我正在尝试显示get Http方法(“/campgrounds”)的对象中的图像。使用CampGrands数组的Get Http方法有3个具有2个属性的对象 如何在主页中显示图像链接 app.set("view engine", "pug"); app.get('/campgrounds', (req, res) => { const campgrounds = [ { Name: "Nam
app.set("view engine", "pug");
app.get('/campgrounds', (req, res) => {
const campgrounds = [
{
Name: "Name1",
Image: "https://images.unsplash.com/photo-1571687949921-1306bfb24b72?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=500&q=60"
},
];
res.render("campgrounds", { campgrounds: campgrounds });
});
这是营地。帕格
html
head
body
h1 This is the Campgrounds Page!
each val in campgrounds
ul
li=val.Name
li=img(src=val.Image) // get the images as stirng links
缩进
img
标记:
each val in campgrounds
ul
li=val.Name
li
img(src=val.Image)