0.1.4 • Published 3 years ago

ddjb-swiper v0.1.4

Weekly downloads
400
License
MTI
Repository
-
Last release
3 years ago

ddjb-swiper

react ddjb-swiper

安装

npm install ddjb-swiper

API

参数说明类型默认值
autoplay可选,自动轮播间隔,单位msnumber3000
duration可选,动画时长,单位msnumber500
initialSwipe可选,默认位置number0
loop可选,是否循环播放booleantrue
vertical可选,是否纵向滑动booleanfalse
touchable可选,是否可手势滑动booleantrue
showIndicators可选,是否显示dotbooleantrue
style可选,容器样式, 纵向时需要设置其高度object-
onSlideChange可选,切换索引的回调function(current)-

方法

名称描述
slideTo(to, swiping)切换到指定索引,swiping = true时,不使用动画
next()切换到下一个索引
prev()切换到上一个索引

基础用法

import React from 'react';
import Swiper from 'ddjb-swiper'

const App = () => {
    return (
        <React.Fragment>
            <div className="title">基础用法</div>
            <Swiper>
                <Swiper.Item key={1}>
                    <div className="block red">1</div>
                </Swiper.Item>
                <Swiper.Item key={2}>
                    <div className="block blue">2</div>
                </Swiper.Item>
                <Swiper.Item key={3}>
                    <div className="block green">3</div>
                </Swiper.Item>
            </Swiper>
        </React.Fragment>
    )
}
.title {
  margin: 0;
  padding: 32px 16px 16px;
  color: rgba(69, 90, 100, 0.6);
  font-weight: normal;
  font-size: 14px;
  line-height: 16px;
  box-sizing: border-box;
}
.block {
  width: 100%;
  height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 20px;
}

.red {
  background-color: coral;
}

.blue {
  background-color: cornflowerblue;
}

.green {
  background-color:darkcyan;
}

示例二维码

npm.io

示例地址

代码拆解

License

MTI © wenlei0617

0.1.2

3 years ago

0.1.1

3 years ago

0.1.4

3 years ago

0.1.3

3 years ago

0.1.0

3 years ago

0.0.9

3 years ago

0.0.8

3 years ago

0.0.7

3 years ago

0.0.6

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.1

3 years ago