swiper6+
https://swiperjs.com/get-started/
安裝
cnpm install --sasve swiper
本次默認安裝的是 6.3.2
引用
import Swiper from 'swiper' // js 模塊 import 'swiper/swiper-bundle.css' // css 模塊
css 的引用位置不在dist 下
初始化
new Swiper('.swiper-container', { // Optional parameters direction: 'vertical', loop: true, // If we need pagination pagination: { el: '.swiper-pagination', }, // Navigation arrows navigation: { nextEl: '.swiper-button-next', prevEl: '.swiper-button-prev', }, // And if we need scrollbar scrollbar: { el: '.swiper-scrollbar', }, })
eslint 下 直接new 報錯 Do not use 'new' for side effects no-new
傳給變量
var swiper = new Swiper(....
又警告 Swiper 從沒被使用過
new 上一行寫 /* eslint-disable no-new */ 繞過
/* eslint-disable no-new */