gpt4 book ai didi

html - 图片没有显示在 html 上用 golang 上的图片书写

转载 作者:IT王子 更新时间:2023-10-29 02:30:14 29 4
gpt4 key购买 nike

在 html 上书写时图像没有显示。

        i can display only image writing on main.go (parsefile).

but writing on html image didnt show.

我试过 html/模板。它也没有用。

代码:_base.html

   <!DOCTYPE html>
<html lang="en">`enter code here`
<head>
<title>{{ template "title" . }}</title>
</head>
<body>
<section id="contents">
{{ template "content" . }}
</section>
<footer id="footer">
My Cool Guestbook 2000 © me forever
</footer>
</body>
</html>

code:(index.html)

{{ define "title" }}Guestbook{{ end }}

{{ define "content" }}
<h1>Guestbook</h1>

<p>Hello, and welcome to my guestbook, because it's 1997!</p>

<ul class="guests">
<li>...</li>
</ul>
<img src="image.png">
{{ end }}

代码:(main.go一些部分)

var index = template.Must(template.ParseFiles(
"templates/_base.html",
"templates/index.html",
))

func hello(w http.ResponseWriter, req *http.Request) {
if err := index.Execute(w, nil); err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
}
}

func main(){ 等等...
Web 应用程序工作正常。但是图片没有显示

最佳答案

打开您的网络浏览器并查看返回的对该图像资源的请求是什么。

它可能会返回 404 Not Found,因为它找不到文件。

例如在 Chrome 中:

image resource chrome developer tools

关于html - 图片没有显示在 html 上用 golang 上的图片书写,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27008262/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com