当前位置: 首页 > news >正文

Shopify Section Rendering API

参考链接:https://shopify.dev/docs/api/ajax/section-rendering

ajax通过section id 获取特定模板的html

id可通过liquid模板拿到{{ section.id }}

获取首页的特定的section,比如a.liquid

    fetch(window.Shopify.routes.root + "?section_id=a").then(res => res.text()).then(domText => {console.log(domText);})

就会得到section a的所有html字符串

获取一组section,比如首页的a.liquid和b.liquid

    fetch(window.Shopify.routes.root + "?sections=header,footer").then(res => res.json()).then(domText => {console.log(JSON.parse(domText));})

得到以下response

获取集合页面的特定section

    fetch(window.Shopify.routes.root + "/collections/{collection_handle}?section_id={section-id}").then(res => res.text()).then(domText => {console.log(domText);})

获取产品页面的特定section

    fetch(window.Shopify.routes.root + "/products/{product_handle}?section_id={section-id}").then(res => res.text()).then(domText => {console.log(domText);})

注意:如果产品A的所属模板是product A模板,那么请求section rendering api只能获取到product A模板的某个section,collection、article同理。

http://www.lryc.cn/news/599869.html

相关文章:

  • 小白如何认识并处理Java异常?
  • 【嵌入式汇编基础】-ARM架构基础(二)
  • 从0到1:初创企业适合做企业架构吗?TOGAF 能带来什么?
  • 小架构step系列25:错误码
  • Haproxy七层代理及配置
  • 数据结构2-集合类ArrayList与洗牌算法
  • 在Word和WPS文字中添加的拼音放到文字右边
  • JS与Go:编程语言双星的碰撞与共生
  • 初识opencv04——图像预处理3
  • ModelWhale+数据分析 消费者行为数据分析实战
  • 判断子序列-leetcode
  • 广州 VR 安全用电技术:工作原理、特性及优势探析​
  • CTF-Web题解:“require_once(‘flag.php‘); assert(“$i == $u“);”
  • Linux系统基本配置以及认识文件作用
  • 双非上岸985!专业课140分经验!信号与系统考研专业课140+上岸中南大学,通信考研小马哥
  • 20分钟学会TypeScript
  • 本地内网IP映射到公网访问如何实现?内网端口映射外网工具有哪些?
  • VUE2 学习笔记6 vue数据监测原理
  • 局域网 IP地址
  • Linux tcpdump 抓取udp 报文
  • 开源语音TTS与ASR大模型选型指南(2025最新版)(疯聊AI提供)
  • 动态规划:从入门到精通
  • 中国开源Qwen3 Coder与Kimi K2哪个最适合编程
  • 电子电子架构 --- 软件项目的开端:裁剪
  • 【IDEA】IDEA中如何通过分支/master提交git?
  • Hadoop 之 Yarn
  • 【软件工程】构建软件合规防护网:双阶段检查机制的实践之道
  • 【AJAX】Promise详解
  • HashMap的线程安全性 vs ConcurrentHashMap
  • 机器学习中knn的详细知识点