![30773459faf0da358d9e073aadca418d.png](https://i-blog.csdnimg.cn/blog_migrate/70eff00de42f51a4852a7280a365b253.jpeg)
在Vue项目中会经常需要实现图片轮播的效果,可以使用vue-awesome-swiper插件快速实现。具体步骤如下:
- 安装vue-awesome-swiper(安装稳定版本2.6.7)
npm install vue-awesome-swiper@2.6.7 --save
2.引入vue-awesome-swiper:一般通过main.js进行全局引入
import VueAwesomeSwiper from 'vue-awesome-swiper'
import 'swiper/dist/css/swiper.css'
Vue.use(VueAwesomeSwiper)
3.使用vue-awesome-swiper插件
![2b2c7833a38f0aa6e6172801b3627e18.png](https://i-blog.csdnimg.cn/blog_migrate/e9dcd6dc4edf3fe443120c979d838847.jpeg)
![02b37f7a2198f96e535a8756822eb53e.png](https://i-blog.csdnimg.cn/blog_migrate/6af298ef1e619792eafaa93552306874.jpeg)
ps: loop:true表示图片可以来回循环显示
![c7945882ce95d4b62b2bc13175aad3e7.png](https://i-blog.csdnimg.cn/blog_migrate/d50c74b86701ba5ff78ee155bc569a47.jpeg)
插件默认显示的圆点为蓝色,若希望自定义颜色,需要使用上图红框的写法,其中 >>> 该句代码表示样式穿透,使用效果不局限于该页面
vue引用了第三方组件,需要在组件中局部修改第三方组件的样式,而又不想去除scoped属性造成组件之间的样式污染。此时只能通过>>>,穿透scoped。