Vue-Awesome-Swiper
轮播图插件,可以同时支持Vue.js(1.X ~ 2.X),兼顾PC和移动端,SPA和SSR。
例子
安装设置
安装Install vue-awesome-swiper
vue挂载
<div class="jb51code">
<pre class="brush:js;">
// 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
// The Process. BROWSER_BUILD
itself is just a feature,it is only valid in Nuxt.js,you need to modify it according to your own procedures,such as: in vue official ssr scaffolding it should beprocess.browser
if (process.BROWSER_BUILD) {
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
}
}