尝试使用golang在DataTable中创建动态URL
想法是要有一些图标可以从表格中删除元素
通过直接传递链接在控制器中创建列 在咨询了BDD之后,所有这些 字符串中串联的变量“ id”代表每个元素
cadenaS := "<a class='links' href='/history/search/" + id + "'><i class='fas fa-search' aria-hidden='true'></i></a>"
cadenaT := "<a class='links' href='/history/delete/" + id + "'><i class='far fa-trash-alt' aria-hidden='true'></i></a>"
his = append(his, History{ID: ID, Email: Email, Search: Search, Tipo: Tipo, Visited: Visited, Icon: &Icon{Search: cadenaS, Trash: cadenaT}})
为显示此消息,只需使用响应json进行呼叫
"columns": [
{"data": "Icon.Search"},
{"data": "Search"},
{"data": "Visited"},
{"data": "Icon.Trash"}
],
将收到删除项目请求的URL
http.HandleFunc("/history/delete/{id}", deleteHistory)
但由于URL中的“ ID”无法识别
,因此从未成功拨打电话