1.0.0 • Published 6 years ago

react-codedown v1.0.0

Weekly downloads
29
License
-
Repository
-
Last release
6 years ago

React Codedown Clock

A simple countdown clock as a React component use typescript.

Installation

npm install react-codedown --save

Usage

import * as React from 'react'
import CountDown from 'react-codedown'

class App extends from React.Component {

    delay = (time) => new Promise((resolve, reject) => {
        setTimeout(resolve, time)
    })

    handleClick = async () => {
        await this.delay(3000)
        this.countdown.reset()
    }

    render(){
        return (    
            <CountDown 
                initialRemaining={60}
                initialContent="获取验证码"
                style={{ width: 80, height: 40 }}
                className="myClass"
                onClick={this.handleClick}
                ref={ref => this.countdown = ref}
                interval={1000}
            />
        )
    }
}

Props

proptypedefaultdescription
initialRemainingnumber60倒计时时间
initialContentstring获取验证码按钮初始文本
styleobject-按钮内联样式
classNamestring-按钮类名
onClickfunction-点击触发的函数
intervalnumber1000时间间隔

methods

start
开始倒计时

reset
重置倒计时

1.0.0

6 years ago

0.1.6

6 years ago

0.1.4

6 years ago

0.1.3

6 years ago

0.1.2

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago