vue轮播图插件vue-awesome-swiper

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
}
}

SPA与SSR中使用方法的区别

SPA通过组件作用,需要借助ref属性查找swiper实例 SSR通过命令作用,需要借助命令参数查找swiper实例 其他配置和事件一致

SSR中的应用

SPA中的应用

<div class="jb51code">
<pre class="brush:js;">

异步数据例子

<div class="jb51code">
<pre class="brush:xhtml;">

移动端例子的代码

SSR例子的代码

API

参考官网:

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持编程之家。

相关文章

https://segmentfault.com/a/1190000022018995 https://www....
ES6 (ECMAScript 6)中的模块是一个包含 JavaScript 代码的...
from https://mp.weixin.qq.com/s/-rc1lYYlsfx-wR4mQmIIQQ V...
D:\Temp&gt;npm init vite@latest vue3study --temp...
文章浏览阅读1.2k次。最近自己从零撸起的甘特图组件需要子组...
文章浏览阅读3.3k次,点赞3次,收藏16次。静默打印是什么?简...