Installations
npm install anx-vue-swiper
Developer Guide
Typescript
No
Module System
CommonJS
Min. Node Version
>= 4.0.0
Node Version
10.1.0
NPM Version
6.3.0
Score
63.6
Supply Chain
97.8
Quality
74.8
Maintenance
25
Vulnerability
99.6
License
Releases
Contributors
Unable to fetch Contributors
Languages
JavaScript (59.82%)
Shell (40.18%)
Developer
Download Statistics
Total Downloads
2,188
Last Day
2
Last Week
13
Last Month
32
Last Year
190
GitHub Statistics
12,839 Stars
299 Commits
1,962 Forks
212 Watching
6 Branches
19 Contributors
Bundle Size
131.83 kB
Minified
34.54 kB
Minified + Gzipped
Package Meta Information
Latest Version
0.0.6
Package Id
anx-vue-swiper@0.0.6
Unpacked Size
32.62 kB
Size
9.52 kB
File Count
10
NPM Version
6.3.0
Node Version
10.1.0
Total Downloads
Cumulative downloads
Total Downloads
2,188
Last day
100%
2
Compared to previous day
Last week
1,200%
13
Compared to previous week
Last month
113.3%
32
Compared to previous month
Last year
-53%
190
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
3
Dev Dependencies
73
Vue-Awesome-Swiper
Swiper4 component for Vue, support pc and mobile, SPA and SSR.
If you need to roll back to Swiper3, use version v2.6.7.
基于 Swiper4、适用于 Vue 的轮播组件,支持服务端渲染和单页应用。
如果需要回退到 Swiper3,请使用 v2.6.7 版本。
Example
Install
CDN
1<link rel="stylesheet" href="path/to/swiper/dist/css/swiper.css"/> 2<script type="text/javascript" src="path/to/swiper.js"></script> 3<script type="text/javascript" src="path/to/vue.min.js"></script> 4<script type="text/javascript" src="path/to/dist/vue-awesome-swiper.js"></script> 5<script type="text/javascript"> 6 Vue.use(window.VueAwesomeSwiper) 7</script>
NPM
1npm install vue-awesome-swiper --save
Mount
mount with global
1import Vue from 'vue' 2import VueAwesomeSwiper from 'vue-awesome-swiper' 3 4// require styles 5import 'swiper/dist/css/swiper.css' 6 7Vue.use(VueAwesomeSwiper, /* { default global options } */)
mount with component
1// require styles 2import 'swiper/dist/css/swiper.css' 3 4import { swiper, swiperSlide } from 'vue-awesome-swiper' 5 6export default { 7 components: { 8 swiper, 9 swiperSlide 10 } 11}
mount with ssr
1// If used in nuxt.js/ssr, you should keep it only in browser build environment 2if (process.browser) { 3 const VueAwesomeSwiper = require('vue-awesome-swiper/dist/ssr') 4 Vue.use(VueAwesomeSwiper) 5}
custom swiper plugin
1import Swiper from 'swiper' 2Swiper.use({ 3 name: 'pluginName', 4 params: { 5 pluginSwitch: false, 6 }, 7 on: { 8 init() { 9 if (!this.params.pluginSwitch) return 10 console.log('init') 11 }, 12 // swiper callback... 13 } 14})
Difference(使用方法的异同)
SSR and the only difference in the use of the SPA:
- SPA worked by the
component
, find swiper instance byref attribute
. - SSR worked by the
directive
, find swiper instance bydirective arg
. - Other configurations, events are the same.
SPA
1<!-- The ref attr used to find the swiper instance --> 2<template> 3 <swiper :options="swiperOption" ref="mySwiper" @someSwiperEvent="callback"> 4 <!-- slides --> 5 <swiper-slide>I'm Slide 1</swiper-slide> 6 <swiper-slide>I'm Slide 2</swiper-slide> 7 <swiper-slide>I'm Slide 3</swiper-slide> 8 <swiper-slide>I'm Slide 4</swiper-slide> 9 <swiper-slide>I'm Slide 5</swiper-slide> 10 <swiper-slide>I'm Slide 6</swiper-slide> 11 <swiper-slide>I'm Slide 7</swiper-slide> 12 <!-- Optional controls --> 13 <div class="swiper-pagination" slot="pagination"></div> 14 <div class="swiper-button-prev" slot="button-prev"></div> 15 <div class="swiper-button-next" slot="button-next"></div> 16 <div class="swiper-scrollbar" slot="scrollbar"></div> 17 </swiper> 18</template> 19 20<script> 21 export default { 22 name: 'carrousel', 23 data() { 24 return { 25 swiperOption: { 26 // some swiper options/callbacks 27 // 所有的参数同 swiper 官方 api 参数 28 // ... 29 } 30 } 31 }, 32 computed: { 33 swiper() { 34 return this.$refs.mySwiper.swiper 35 } 36 }, 37 mounted() { 38 // current swiper instance 39 // 然后你就可以使用当前上下文内的swiper对象去做你想做的事了 40 console.log('this is current swiper instance object', this.swiper) 41 this.swiper.slideTo(3, 1000, false) 42 } 43 } 44</script>
Async data example
1<template> 2 <swiper :options="swiperOption"> 3 <swiper-slide v-for="(slide, index) in swiperSlides" :key="index">I'm Slide {{ slide }}</swiper-slide> 4 <div class="swiper-pagination" slot="pagination"></div> 5 </swiper> 6</template> 7 8<script> 9 export default { 10 name: 'carrousel', 11 data() { 12 return { 13 swiperOption: { 14 pagination: { 15 el: '.swiper-pagination' 16 } 17 }, 18 swiperSlides: [1, 2, 3, 4, 5] 19 } 20 }, 21 mounted() { 22 setInterval(() => { 23 console.log('simulate async data') 24 if (this.swiperSlides.length < 10) { 25 this.swiperSlides.push(this.swiperSlides.length + 1) 26 } 27 }, 3000) 28 } 29 } 30</script>
SSR
1<!-- You can custom the "mySwiper" name used to find the swiper instance in current component --> 2<template> 3 <div v-swiper:mySwiper="swiperOption" @someSwiperEvent="callback"> 4 <div class="swiper-wrapper"> 5 <div class="swiper-slide" v-for="banner in banners"> 6 <img :src="banner"> 7 </div> 8 </div> 9 <div class="swiper-pagination"></div> 10 </div> 11</template> 12 13<script> 14 export default { 15 data () { 16 return { 17 banners: [ '/1.jpg', '/2.jpg', '/3.jpg' ], 18 swiperOption: { 19 pagination: { 20 el: '.swiper-pagination' 21 }, 22 // some swiper options... 23 } 24 } 25 }, 26 mounted() { 27 setTimeout(() => { 28 this.banners.push('/4.jpg') 29 console.log('banners update') 30 }, 3000) 31 console.log( 32 'This is current swiper instance object', this.mySwiper, 33 'It will slideTo banners 3') 34 this.mySwiper.slideTo(3, 1000, false) 35 } 36 } 37</script>
API
Swiper's API and configuration can be used.(Swiper官网中的API及配置均可使用)
Author
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
2 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-mwcw-c2x4-8c55
- Warn: Project is vulnerable to: GHSA-7fh5-64p2-3v2j
Reason
Found 1/30 approved changesets -- score normalized to 0
Reason
project is archived
Details
- Warn: Repository is archived.
Reason
detected GitHub workflow tokens with excessive permissions
Details
- Warn: no topLevel permission defined: .github/workflows/publish.yml:1
- Warn: no topLevel permission defined: .github/workflows/release.yml:1
- Info: no jobLevel write permissions found
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/publish.yml:18: update your workflow using https://app.stepsecurity.io/secureworkflow/surmon-china/vue-awesome-swiper/publish.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/publish.yml:19: update your workflow using https://app.stepsecurity.io/secureworkflow/surmon-china/vue-awesome-swiper/publish.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yml:16: update your workflow using https://app.stepsecurity.io/secureworkflow/surmon-china/vue-awesome-swiper/release.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yml:20: update your workflow using https://app.stepsecurity.io/secureworkflow/surmon-china/vue-awesome-swiper/release.yml/main?enable=pin
- Info: 0 out of 4 GitHub-owned GitHubAction dependencies pinned
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'main'
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 3 are checked with a SAST tool
Score
3.2
/10
Last Scanned on 2025-01-27
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More