我有一个结构:
type Records []struct {
Example string `json:"example"`
Data string `json:"data"`
}
type Response struct {
RecordsCount int `json:"recordsCount"`
Records []Records `json:"records"`
}
但我想在折叠的 html 部分中显示它,如下所示:
<div class="collapse">
<input type="checkbox" id="collapse-section1" checked aria-hidden="true">
<label for="collapse-section1" aria-hidden="true">Collapse section 1</label>
<div>
<p>This is the first section of the collapse</p>
</div>
<input type="checkbox" id="collapse-section2" aria-hidden="true">
<label for="collapse-section2" aria-hidden="true">Collapse section 2</label>
<div>
<p>This is the second section of the collapse</p>
</div>
</div>
但为了做到这一点,我需要某种 ID 来替换实际id=""的labeland input。
但这就是问题所在,我的结构没有 ID;有时数据是重复的(我希望将其包含在内),因此为了正确执行此操作,我必须生成一个 ID,然后将其附加到切片中,然后这样做。
我不知道该怎么做。有人可以指出我正确的方向吗?
红颜莎娜
相关分类