如何在GAE GO中的html模板中執行條件語句?我試圖做到這一點,以便在select html標記中選擇一個選項:<select name=".Grade"> <option value=""></option> <option value="1" {{ if .Grade="1" }} selected="selected" {{ end }}>Grade One</option> <option value="2" {{ if .Grade="2" }} selected="selected" {{ end }}>Grade Two</option> <option value="3" {{ if .Grade="3" }} selected="selected" {{ end }}>Grade Three</option> <option value="4" {{ if .Grade="4" }} selected="selected" {{ end }}>Grade Four</option> <option value="5" {{ if .Grade="5" }} selected="selected" {{ end }}>Grade Five</option> <option value="6" {{ if .Grade="6" }} selected="selected" {{ end }}>Grade Six</option></select>有{{ if .Grade }} selected="selected" {{ end }} 在參考文檔中,但這僅在.Grade有值時評估為true 。任何幫助將不勝感激。謝謝!
- 1 回答
- 0 關注
- 208 瀏覽
添加回答
舉報
0/150
提交
取消