使用vue配置輪播圖
阿新 • • 發佈:2022-05-11
步驟:
1.新建components / swiperCom.vue
2.聯絡swiperCom.vue 與 HomeView.vue
3在HomeView.vue 中引入配置swiperCom.vue
<!-- 在music002中安裝輪播圖安裝包--> <!-- npm i swiper vue-awesome-swiper --save --> <!-- npm i swiper@5 --save --> <template> <div id="swipercom"> <div class="swiper-container" id="swiperIndex"> <div class="swiper-wrapper"> <div class="swiper-slide" v-for="(item,i) in imgs" :key="i"> <img :src="item.pic" alt=""> </div> </div> <!--分頁器--> <div class="swiper-pagination"></div> </div> </div> </template> <script> // 引入輪播圖 import 'swiper/css/swiper.css' import Swiper from 'swiper export default { name: "swiperCom", data() { return { imgs: [{}, {}, {}] } }