⚠ 平台测试中。

🖼️ 内容多图遍历

最后更新:2026-10-02

⚡ 基本语法

<!-- 解析 JSON 数组为切片 -->
{{range splitJSON .Images}}
<img src="{{.}}" alt="" loading="lazy">
{{end}}

📋 适用字段

{{.News.Images}}文章多图列表JSON
{{.Product.Images}}产品多图列表JSON
{{.Case.Images}}案例多图列表JSON
{{.News.Attachments}}文章附件列表JSON

💻 完整示例

<!-- 产品详情页轮播图(产品多图) -->
<div class="product-gallery">
  {{range splitJSON .Product.Images}}
  <img src="{{.}}" alt="" loading="lazy">
  {{end}}
</div>

<!-- 文章详情页附图(文章多图) -->
{{range splitJSON .News.Images}}
  <figure>
    <img src="{{.}}" alt="" loading="lazy">
  </figure>
{{end}}

<!-- 文章附件下载列表 -->
{{range splitJSON .News.Attachments}}
  <a href="{{.}}" class="attachment" download>下载附件</a>
{{end}}

注意:splitJSON 对 nil / 空字符串安全(返回空切片,不报错)。

本网站使用 Cookie 以提升浏览体验,继续浏览即表示您同意我们的 Cookie 政策。