效果
源码
go
type data struct {
Name string // 插件名称
Standard string // 标准版本
Local string // 本地版本
Package string // 包名
Result string // 对比结果
}
func (api *User) searchHtml() {
dataList := []data{
{"Wps", "10489", "10489", "wps", "正确"},
{"Wps", "10489", "10489", "wps", "正确"},
{"Wps", "10489", "10489", "wps", "正确"},
{"Wps", "10489", "10489", "wps", "正确"},
{"Wps", "10489", "10489", "wps", "正确"},
{"Wps", "10489", "10489", "wps", "正确"},
{"Wps", "10489", "10489", "wps", "正确"},
{"Wps", "10489", "10489", "wps", "正确"},
{"Wps", "10489", "10489", "wps", "正确"},
{"Wps", "10489", "10489", "wps", "正确"},
{"Wps", "10489", "10489", "wps", "正确"},
{"Wps", "10489", "10489", "wps", "正确"},
{"Wps", "10489", "10489", "wps", "正确"},
{"Wps", "10489", "10489", "wps", "正确"},
}
api.Route.GET("/cha", func(c *gin.Context) {
c.HTML(http.StatusOK, "index.html", gin.H{
"title": "查询结果",
"data": dataList,
})
})
}
html
<!DOCTYPE html>
<html lang="zh">
<head>
<meta name="viewport" content="width=device-width" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>{{.title}}</title>
<link rel="stylesheet" href="/static/css/install.css" type="text/css" />
</head>
<body>
<table>
<tr>
<th>插件名称</th><th>标准版本</th><th>本地版本</th><th>包名</th><th>对比结果</th>
</tr>
{{ range .data }}
<tr>
<td>{{ .Name }}</td><td>{{ .Standard }}</td><td>{{ .Local }}</td><td>{{ .Package }}</td><td>{{ .Result }}</td>
</tr>
{{ end }}
</table>
</body>
</html>