找不到GET /media/image_test.png的路由

问题描述 投票:1回答:1

我正在尝试使用<%= img_tag("/media/image_test.png") %>显示图像image_test.png位于文件夹“ media”中,该文件夹位于我的项目文件夹“ practice”的根目录中。

但是我得到错误,找不到GET /media/image_test.png的路由

下面是我文件的内容:

practice / media / image_test.png

图像

practice / lib / practice_web / templage / index.html.eex

<%= img_tag("/media/1570573826060_.png") %>

很明显,图像路径不是核心。

您能帮忙吗?

elixir phoenix-framework
1个回答
1
投票
<img src="<%= static_path(@conn, "/media/1570573826060_.png") %>">
尝试这个,您应该使用静态路径访问它们
© www.soinside.com 2019 - 2024. All rights reserved.