GithubHelp home page GithubHelp logo

hhy5277 / vue-swiper-1 Goto Github PK

View Code? Open in Web Editor NEW

This project forked from zwhgithub/vue-swiper

0.0 1.0 0.0 1.14 MB

✅ 轻量、高性能轮播插件。目前支持 无缝衔接自动轮播、无限轮播、手势轮播

JavaScript 68.80% HTML 0.97% Vue 30.23%

vue-swiper-1's Introduction

vue-swiper

  • 基于 Vue2.0 开发,基本满足大部分功能。
  • 轻量、高性能轮播插件。目前支持 无缝衔接自动轮播、无限轮播、手势轮播。
  • 没有引入第三方库,原生 js 封装,打包之后只有 8.2KB 大小 性能还是杠杠滴。

github地址

demo

效果

🎉 觉得好用给一个 star 哦~ 🎉

Install

npm i vue-swiper-component --save
cnpm i vue-swiper-component --save  //国内镜像

Usage

import { Swiper, Slide } from 'vue-swiper-component';

components: {
    Swiper,
    Slide
}

//异步加载轮播图的情况;
  <Swiper v-if="list.length > 0">
       <Slide v-for="(item,index) in list" :key="index">
       </Slide>
  </Swiper>


 //同步加载轮播图情况
  <Swiper>
       <Slide>
               1
       </Slide>
       <Slide>
       		2
       </Slide>
       <Slide>
       		3
       </Slide>
  </Swiper>

    //加一些参数配置情况
  <Swiper v-if="slidesReal.length > 0" :autoPlay='true' :showIndicator='true' interval="2500" duration="500">
        <Slide @click="clickMe" v-for="(item,index) in slidesReal" :key="index">
        	//添加click事件
        </Slide>
   </Swiper>

API

属性 说明 默认
autoPlay 是否自动轮播 true
showIndicator 是否显示轮播的那个点 true
interval 每两次隔多久滚动一次 2500
duration 每次滚动一页需要多久时间 500
  Swiper 上面还暴露了其他方法, Swiper 标签上添加 ref 属性, 例如: <Swiper ref="swiper"></Swiper>

    ✅  this.$refs.swiper.prevSlide(); // 上一张图
    ✅  this.$refs.swiper.nextSlide(); // 下一张图
    ✅  this.$refs.swiper.slideTo(2); //某一张图

事件

transtionend 事件  每次轮播出发 参数表示轮播到第几个图片 在Swiper上添加
// @transtionend="getNum"    getNum(data) {console.log(data);}
click  事件 每个轮播图上的事件

Other

  • 可以通过覆盖我的样式进行自定义样式,Slide 标签里面可以写 div 或者其他的东西
  • 一些参数配置可以参考上面 Usage 第三个示例,异步渲染要加 v-if 保证渲染成功 参考第一个示例
  • 如果其他问题可以邮箱沟通,[email protected];
  • 暂时对 PC 支持不是很友好,等以后有时间了可以加上;

vue-swiper-1's People

Contributors

zwhgithub avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.