如何在Vue项目中优雅的使用swiper插件

开始之前,请先确保有一个基于webpack模板的项目(vue-cli脚手架一键安装~)

1.npm命令安装swiper

npm install swiper --save-dev

2.在需要用到swiper插件的组件中引入swiper

import Swiper from "swiper"

3.在组件style中引入swiper插件的css(根据自己的项目路径选择)


4.在methods方法里面初始化swiper插件


5.在created钩子函数里面调用


OK......

猜你喜欢

转载自blog.csdn.net/twodogya/article/details/80199967