使用EJ时,IMG标签不显示图像

发布于 2025-02-10 12:49:22 字数 590 浏览 1 评论 0原文

我正在与Express,EJS和Mongoose合作。我在MongoDB中列出了产品列表,我想显示在本地存储中存储的产品的图像。我使用express.static方法访问图像。我的图像命名为Samsung Galaxy M33 5G(Emarld Brown,128 GB)(6 GB RAM),我将它们的名称保存在一个称为类别的数组(类似于对象)中。 在这种情况下,我的代码正在遵循

    <% for( list of category){ %> 
        <ul>
            <img src="/<%=list.name%>.jpeg" alt="<%=list.name %>">
            <li><%= list.name %> </li>
        </ul>
     <% } %>

未显示的图像,但是当我从图像名称中删除括号()时(如三星Galaxy M33 5G Emarld Brown,128 GB 6 GB RAM),它开始像Wonder一样工作,但我有很多图像我无法更改所有图像的名称,请帮助我解决这个问题

I'm working with express, ejs and mongoose . i have list of products in mongoDB and i want to display images of products which is store in my local storage. i used express.static method to access images. my images named like this SAMSUNG Galaxy M33 5G (Emarld Brown, 128 GB) (6 GB RAM) , i saved their name in an array ( like object ) called category. my code is following

    <% for( list of category){ %> 
        <ul>
            <img src="/<%=list.name%>.jpeg" alt="<%=list.name %>">
            <li><%= list.name %> </li>
        </ul>
     <% } %>

in this case no image is displayed but when i removed brackets () from the name of image ( like this SAMSUNG Galaxy M33 5G Emarld Brown, 128 GB 6 GB RAM ) it start working like wonder but i have so many images and i cant change name of all images please help me to solve this problem

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文