jQuery(document).ready(function($) { // — 简化循环逻辑 — constwrapper = $('.slider-wrapper'); const slipCount = $('.slider-slide').length; let currentSlide = 0; $('.slider-nav-next').on('click', function() { currentSlide = (currentSlide + 1) % slipCount; } wrapper.css('transform', 'translateX(' + (-currentSlide * 100 / slipCount) + '%)'); $('.slider-nav-prev').on('click', function() { currentSlide = (currentSlide – 1 + slipCount) % slipCount;wrapper.css('transform', 'translateX(' + (-currentSlide * 100) / SlideCount) + '%)'); }); // — 平滑滚动逻辑(未更改) — $('.promo-scroll-link').on('click', function(e) { e.preventDefault(); var destination = $(this).attr('href'); setTimeout(function() { if ($(destination).length) { $('html, body').animate({ scrollTop: $(destination).offset().top – 122 }, 800); } }, 300); }); });