新问题
在练习基于 Go 语言构建在线论坛(五):创建群组和主题功能实现
的时候遇到了一些问题。
访问群组页面的时候,并没有出现回复框。其中views
下的文件都是一致的。
这是handlers/thread.go
func ReadThread(writer http.ResponseWriter, request *http.Request) {
vals := request.URL.Query()
uuid := vals.Get("id")
thread, err := models.ThreadByUUID(uuid)
if err != nil {
fmt.Println("Cannot read thread",err)
} else {
_, err := session(writer, request)
if err != nil {
generateHTML(writer, &thread, "layout", "navbar", "thread")
} else {
generateHTML(writer, &thread, "layout", "auth.navbar", "auth.thread")
}
}
}
这是创建群组页面的handlers\thread\NewThread.go
func NewThread(writer http.ResponseWriter, request *http.Request) {
_, err := session(writer, request)
if err != nil {
http.Redirect(writer, request, "/login", 302)
} else {
generateHTML(writer, nil, "layout", "auth.navbar", "new.thread")
}
}
这是new.thread.html
{{ define "content" }}
<form role="form" action="/thread/create" method="post">
<div class="lead">Start a new thread with the following topic</div>
<div class="form-group">
<textarea class="form-control" name="topic" id="topic" placeholder="Thread topic here" rows="4"></textarea>
<br/>
<br/>
<button class="btn btn-lg btn-primary pull-right" type="submit">Start this thread</button>
</div>
</form>
{{ end }}
经过多次排查,还是找不到问题..
2 Comments
这是
views/auth.thread.html
看了一下网站页面代码,不知道为什么没有
页面源码看了吗 F12 看看有无报错信息 可以微信里面私聊下我