Browse Source

feat(product.js): 相关产品模块不超过4个时。不展示切换按钮。

master
peijunlei 1 week ago
parent
commit
f26f98c02a
  1. 8
      public/themes/dist_static/static/js/product.js

8
public/themes/dist_static/static/js/product.js

@ -32,10 +32,18 @@ function relatedCarouselInit() {
const root = document.querySelector(".p-related");
const el = root?.querySelector(".p-related__swiper");
if (!root || !el || !window.Swiper) return;
const slideCount = el.querySelectorAll(".swiper-wrapper > .swiper-slide").length;
// 一屏展示 4 条,不超过 4 条时隐藏切换按钮
if (slideCount <= 4) {
root.querySelectorAll(".p-related__header .s-arrows").forEach((node) => {
node.style.display = "none";
});
}
new window.Swiper(el, {
slidesPerView: 1.15,
spaceBetween: 16,
grabCursor: true,
watchOverflow: true,
pagination: {
el: root.querySelector(".p-related__pagination"),
clickable: true

Loading…
Cancel
Save