swiper6+安裝問題


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 */

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM