https://blog.csdn.net/weixin_43227172/article/details/86542438(copy)css
開始以前,請先確保有一個基於webpack模板的項目(vue-cli腳手架一鍵安裝~)vue
1.npm命令安裝swiper
npm install swiper --save-dev
2.在須要用到swiper插件的組件中引入swiper
import Swiper from "swiper"
3.在組件style中引入swiper插件的css(根據本身的項目路徑選擇)webpack
@import 'swiper/dist/css/swiper.css';web
4.在methods方法裏面初始化swiper插件vue-cli
5.在created鉤子函數裏面調用npm