先创建项目( 这儿使用的是yarn 使用npm也可以 )
yarn create @vitejs/app my-vue-app --template vue
cd my-vue-app
yarn
yarn dev
安装完成以后的样子
然后安装swiper
yarn add swiper
下载完swiper要引入 ( 此处是全局引入 )
在components下创建一个swiper.js
swiper.js里面的代码
import { createApp } from 'vue'
const app = createApp()
import { Swiper, SwiperSlide } from 'swiper/vue'
//根据需要加载所需模块( 这儿只需要左右箭头 就没导入其他模块 )
import SwiperCore, { Navigation } from 'swiper'
import 'swiper/swiper-bundle.css'
SwiperCore.use([Navigation])
const plugins = [Swipe