使用EJ时,IMG标签不显示图像
我正在与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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论