将 Int64ToString 改为 Uint64ToString后,删除按钮依旧不会展现出来
1. 运行环境
MacOS Monterey 12.0.1
go version go1.17.2 darwin/amd64
2. 问题描述?
articles_controller.go
tmpl, err := template.New("show.gohtml").
Funcs(template.FuncMap{
"RouteName2URL": route.Name2URL,
"Uint64ToString": types.Uint64ToString,
}).
ParseFiles("resources/views/articles/show.gohtml")
logger.LogError(err)
tmpl.Execute(w, article)
show.gohtml
{{/* 构建删除按钮 */}}
{{ $idString := Uint64ToString .ID }}
<form action="{{ RouteName2URL "articles.delete" "id" $idString }}" method="post">
<button type="submit" onclick="return confirm('删除动作不可逆,请确定是否继续')">删除</button>
</form>
articles_controller.go 文件里,下面这一行:
改为:
然后刷新页面,再看下终端里显示什么。