使用vue2以及swiper5.4.5 vue-awesome-swiper实现轮播效果
首先使用命令行
1安装
cnpm install swiper@5.4.5 vue-awesome-swiper --save
swiper一定要是5.4.5版本,安装完成后
main.js中引入做全局注册
import Vue from 'vue'
import App from './App.vue'
import VueAwesomeSwiper from 'vue-awesome-swiper'
import 'swiper/css/swiper.css'
Vue.config.productionTip = false
Vue.use(VueAwesomeSwiper)
new Vue({
render: h => h(App),
}).$mount('#app')
在自己创建的组件中 .vue文件中写入
<template>
<swiper ref="mySwiper" :options="swiperOptions">
<swiper-slide>Slide 1</swiper-slide>
<swiper-slide>Slide 2</swiper-slide>
<swiper-slide>Slide 3</swiper-slide>
<swiper-slide>Slide 4</swiper-slide>
<swiper-slide>Slide 5</swiper-slide>
<div