나는 여러 개의 슬라이더 인스턴스를 가지고 있으며 모든 매개 변수에 동일한 매개 변수를 전달해야합니다.자바 스크립트에서 배열로 매개 변수 전달
내가 배열이 필요하다고 가정하지만, JS에서 초보자이기 때문에 제대로 수행하는 방법을 잘 모르겠습니다.
spaceBetween: 20,
slidesPerView: 5,
breakpoints: {
600: {
slidesPerView: 2
},
991: {
slidesPerView: 3
},
1200: {
slidesPerView: 4
}
}
와 슬라이더 예 :
var swiper1 = new Swiper('.swiper1', {
prevButton: '.b-prev-1',
nextButton: '.b-next-1',
//here I need to get the rest of the parameters
});
당신 :
보기 .extend' $'에서 - 당신이'가질 수 있도록 함께 객체를 병합 할 수 있습니다 var에 commonOpts = {spaceBetween : 20 ...} 다음'과'$ .extend ({ }, commonOpts, swiper1Opts)' – vlaz