我从教程文档中有简单的 codeigniter4 项目设置:https ://codeigniter4.github.io/userguide/tutorial/static_pages.html
问题是即使 src 路径正确,浏览器也没有显示图片。正如您在下面看到的,我尝试使用 url helper,尝试了相对路径,但没有任何效果。我什至删除了 .htacces 文件,但仍然没有。重要的是这是 codeigniter 问题,因为我在我的 vanilla 项目中尝试过这个并且它有效。
<img src="<?php echo base_url('/public/imgs/glacier.jpg')?>" alt="glacier">
<img src="/public/imgs/orbs.jpg" alt="orbs">
我的图片在 public/imgs 文件夹中。这是来自浏览器控制台的错误:
Loading failed for the <script> with source “http://localhost:8080/codeigniter4/index.php?debugbar”. home:6:1
我才开始使用 codeigniter4,所以这真的让我很沮丧。这让我疯狂 :(
PS.我希望我已经提供了所需的所有信息,因为这是我的第一个问题。我期待着答案:)