[![](https://badge.juejin.im/entry/57f6a5e7d2030900689c1e9c/likes.svg?style=flat-square)](https://juejin.im/entry/57f6a5e7d2030900689c1e9c/detail) [![GitHub issues](https://img.shields.io/github/issues/surmon-china/vue-awesome-swiper.svg?style=flat-square)](https://github.com/surmon-china/vue-awesome-swiper/issues) [![GitHub forks](https://img.shields.io/github/forks/surmon-china/vue-awesome-swiper.svg?style=flat-square)](https://github.com/surmon-china/vue-awesome-swiper/network) [![GitHub stars](https://img.shields.io/github/stars/surmon-china/vue-awesome-swiper.svg?style=flat-square)](https://github.com/surmon-china/vue-awesome-swiper/stargazers) [![Twitter](https://img.shields.io/twitter/url/https/github.com/surmon-china/vue-awesome-swiper.svg?style=flat-square)](https://twitter.com/intent/tweet?url=https://github.com/surmon-china/vue-awesome-swiper) [![NPM](https://nodei.co/npm/vue-awesome-swiper.png?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/vue-awesome-swiper/) [![NPM](https://nodei.co/npm-dl/vue-awesome-swiper.png?months=9&height=3)](https://nodei.co/npm/vue-awesome-swiper/) # Vue-Awesome-Swiper Swiper([Swiper3](http://www.swiper.com.cn)) component for Vue, support pc and mobile, SPA and SSR. # Example [Demo Page](https://surmon-china.github.io/vue-awesome-swiper) # Use Setup for Browser ### Require script and style ``` html ``` ### Use ``` javascript Vue.use(window.VueAwesomeSwiper) // vue app code... ``` # Use Setup for Webpack ### Install vue-awesome-swiper ``` bash npm install vue-awesome-swiper --save ``` ### Vue mount ``` javascript // starting with version 2.6.0, you need to manually introduce swiper's css require('swiper/dist/css/swiper.css') // import import Vue from 'vue' import VueAwesomeSwiper from 'vue-awesome-swiper' // or require var Vue = require('vue') var VueAwesomeSwiper = require('vue-awesome-swiper') // mount with global Vue.use(VueAwesomeSwiper) // If used in Nuxt.js/SSR, you should keep it only in browser build environment if (process.browser) { const VueAwesomeSwiper = require('vue-awesome-swiper/ssr') Vue.use(VueAwesomeSwiper) } // mount with component(can't work in Nuxt.js/SSR) import { swiper, swiperSlide } from 'vue-awesome-swiper' export default { components: { swiper, swiperSlide } } ``` ### Use the difference(使用方法的区别) **SSR and the only difference in the use of the SPA:** - SPA worked by the `component`, find swiper instance by `ref attribute`. - SSR worked by the `directive`, find swiper instance by `directive arg`. - Other configurations, events are the same. ### Use in SSR ``` vue ``` ### Use in SPA ``` vue ``` ### Async data example ``` vue ``` # Mobile Example Code [mobile-fullpage-example-code](https://github.com/surmon-china/vue-awesome-swiper/blob/master/examples/41-mobile-fullpage-example.vue) # Nuxt.js/SSR Example Code [nuxt.js/ssr-example-code](https://github.com/surmon-china/vue-awesome-swiper/blob/master/nuxt-ssr-example) # Issues 针对中文用户:如果你有未解决的问题请一定要在已关闭的 issues 里进行搜索,绝大多数问题能够得到答案;提问题之前一定要自行测试问题节点,测试出问题所在,若为自身业务问题或基础知识问题或 swiper 本身的问题,问题会被直接关闭。 # API Swiper's API and configuration can be used.(Swiper官网中的API及配置均可使用) - [cn Swiper3 apis](http://www.swiper.com.cn/api/index.html) - [en Swiper3 apis](http://idangero.us/swiper/api/#.WMlhYxJ97mI) # Author Blog [Surmon](https://surmon.me)