跳到主要内容

Section assets

Section 可以使用以下 section 专用 Liquid tag 打包自己的 JavaScript 和样式表资源:

javascript

{% javascript %} tag 可用于为 section 引入 JavaScript:

{% javascript %}
const type = document.querySelector('.product-detail').dataset.productId;
{% endjavascript %}

{% javascript %} tag 中的内容会被注入到 </body> 标签之前。

每个 {% javascript %} tag 中的内容需要包裹在自执行匿名函数中,以便将变量限定在闭包内,避免运行时异常影响其他 section。

stylesheet

{% stylesheet %} tag 可用于为 section 引入 CSS 样式:

<div class="product-detail">
<!-- 商品详情内容 -->
</div>

{% stylesheet %}
.product-detail {
margin-top: 100px;
margin-bottom: 100px;
}
{% endstylesheet %}

{% stylesheet %} tag 中的内容将被放置在 section 元素之前的位置。