你能帮忙吗,我面临以下异常,不知道如何处理。
我在sliders.js 中有一个代码
const btnContainer1 = document.querySelector('.arrow-buttons-wrap');
const sliderBody1 = document.querySelector('.latest-portfolio-slider');
const sliderItems1 = document.getElementsByClassName('latest-portfolio__card');
const sliderLine1 = document.querySelector('.latest-portfolio-slider-line');
const sliderBody2 = document.querySelector('.testimony-slider');
const sliderLine2 = document.querySelector('.testimony-slider-line');
const sliderItems2 = document.querySelectorAll('.slider-item');
const btnContainer2 = document.querySelector('.latest-testimonials__content');
export function Slider(btnContainer, sliderBody, sliderItems, sliderLine) {
this.INTERVAL = 2000;
this.count = 0;
this.width;
this.id = setInterval( () => { this.next() }, this.INTERVAL );
this.rollSlider = function() {
sliderLine.style.transform = `translate(-${this.count * this.width}px)`;
};
this.prev = function() {
clearInterval(this.id);
sliderLine.prepend(sliderItems[sliderItems.length - 1]);
this.rollSlider();
this.id = setInterval( () => { this.prev() }, this.INTERVAL );
};
this.next = function() {
clearInterval(this.id);
sliderLine.append(sliderItems[0]);
this.rollSlider();
this.id = setInterval( () => { this.next() }, this.INTERVAL );
};
this.onClick = function(e) {
let act = e.target.dataset.act;
if (act) {
this[act]();
}
};
}
有一个规范文件
我不知道如何解决它。如果你只是显示一个方向,那就太棒了!