验证码输入框的 React 实现.
yarn add @axetroy/react-codebox
import React, { Component } from "react";
import Codebox from "@axetroy/react-codebox";
class App extends Component {
render() {
return (
<div>
<Codebox
type="text"
length={4}
validator={(input, index) => {
return /\d/.test(input);
}}
onChange={codeArray => {
console.log(codeArray);
}}
/>
</div>
);
}
}
The MIT License