【发布时间】:2018-09-22 14:40:25
【问题描述】:
我想为列表中的特定项目使用默认值。 我尝试了以下代码,但出现“unexpected "=" in operand 错误 " 我该如何处理这个问题?
<select name="location_id">
{{ range .LocationList}}
<option value="{{ .Id }}" {{if .Name == .CurrentLocation}}selected{{end}}>{{ .Name }}</option>
{{ end }}
</select>
【问题讨论】:
-
{{if eq .Name .CurrentLocation}} -
非常感谢@MartinGallagher。效果很好
标签: html templates go html-select