【问题标题】:images not showing on vscod Browser Preview图片未在 vscode 浏览器预览中显示
【发布时间】:2022-01-23 04:50:18
【问题描述】:

在此不胜感激,我的 img html 标记具有正确的文件路径。但是,当我启动 express 服务器并尝试在 vscod 浏览器预览中查看图像时,我看不到它(下面链接中的示例图片)。可能是什么问题?

 <div class="dashboard"><!--Dashboard START-->
    <section class="navigation"><!--Navigation START-->
        <img src="imgs/iHome.png" alt="">
    </section><!--Navigation END-->

This is a picture of the html file along with the directories on the left and the html img tag in the middle, and the Browser Preview with the missing image on the right

【问题讨论】:

    标签: html express vscode-extensions


    【解决方案1】:

    应用程序需要一个 src 文件夹,其中包含一个子文件夹 assets。您的前端 js 应该托管在 src 文件夹中。 把你的图片放在 src -> assets -> images/pic01.jpeg

    然后这样称呼它:

            <img src="assets/images/pic01.png" alt="">
    

    【讨论】: