如何安装swiper6.8.1对应的vue-awesome-swiper
时间: 2023-07-11 08:48:34 浏览: 141
你可以通过以下步骤安装 `vue-awesome-swiper`:
1. 首先,安装 `swiper` 和 `vue-awesome-swiper`:
```
npm install swiper@6.8.1 vue-awesome-swiper --save
```
2. 在你的 `main.js` 中引入 `vue-awesome-swiper`:
```javascript
import Vue from 'vue'
import VueAwesomeSwiper from 'vue-awesome-swiper'
// 引入样式
import 'swiper/swiper-bundle.css'
import 'vue-awesome-swiper/node_modules/swiper/swiper-bundle.min.css'
Vue.use(VueAwesomeSwiper, /* { default options with global component } */)
```
3. 在你的组件中使用 `vue-awesome-swiper`:
```vue
<template>
<div class="swiper">
<swiper :options="swiperOption">
<swiper-slide v-for="(slide, index) in bannerImg" :key="index">
<img :src="slide" alt="" />
</swiper-slide>
<div class="swiper-pagination" slot="pagination"></div>
</swiper>
</div>
</template>
<script>
export default {
data() {
return {
swiperOption: {
loop: true
},
bannerImg: [
require("../../../assets/slideShow/j1.jpg"),
require("../../../assets/slideShow/j2.jpg"),
require("../../../assets/slideShow/j3.jpg"),
require("../../../assets/slideShow/j4.jpg"),
],
};
},
};
</script>
```
如果你需要更详细的配置,可以参考 `vue-awesome-swiper` 的文档。
阅读全文