-3

我无法弄清楚错误是什么(错误:未捕获的引用错误)

(slidesWrapper = document.querySelector(wrapper)) - 在滑块

  const slides = document.querySelectorAll(slide),
    slider = document.querySelector(container),
    prev = document.querySelector(prevArrow),
    next = document.querySelector(nextArrow),
    total = document.querySelector(totalCounter),
    current = document.querySelector(currentCounter);
  (slidesWrapper = document.querySelector(wrapper));
    (width = window.getComputedStyle(slidesWrapper).width);
    (slideField = document.querySelector(field));

数据导出到另一个文档

未捕获的 ReferenceError:未定义 slidesWrapper

slider({
    container: ".offer__slider",
    slide: ".offer__slide",
    nextArrow: ".offer__slider-next",
    prevArrow: ".offer__slider-prev",
    totalCounter: "#total",
    currentCounter: "#current",
    wrapper: ".offer__slider-wrapper",
    field: ".offer__slider-inner"
  });




  
4

1 回答 1

0

您正在使用单个变量定义多个变量,const其中每个变量用逗号分隔。

代码应该是这样的:

const slides = document.querySelectorAll(slide),
    slider = document.querySelector(container),
    prev = document.querySelector(prevArrow),
    next = document.querySelector(nextArrow),
    total = document.querySelector(totalCounter),
    current = document.querySelector(currentCounter,
    slidesWrapper = document.querySelector(wrapper),
    width = window.getComputedStyle(slidesWrapper).width,
    slideField = document.querySelector(field);
于 2021-10-31T18:06:13.523 回答