反应-本土-资金投入
完全的本土资金投入 反应土著。 基于原始文本输入组件 .
示例
| iOS系统 | 机器人 |
|---|---|
![]() | ![]() |
* 安装
yarn add @alexzunik/react-native-money-input
npx pod-install
使用量
import { MoneyTextInput } from '@alexzunik/react-native-money-input';
// ...
const Component = () => {
const [value, setValue] = React.useState<string>();
return (
<MoneyTextInput
value={value}
onChangeText={(formatted, extracted) => {
console.log(formatted) // $1,234,567.89
console.log(extracted) // 1234567.89
setValue(extracted)
}}
prefix="$"
groupingSeparator=","
fractionSeparator="."
/>
)
}
++ Propals 软件
该组件完全继承了文本输入道具并带来了新的道具. 见下文:
export interface MoneyTextInputProps extends TextInputProps, MaskOptions {
/**
* Callback with entered value
*
* @param formatted {string} formatted text
* @param extracted {string} extracted text
*/
onChangeText: (formatted: string, extracted?: string) => void;
}
interface MaskOptions {
/**
* Separator between integer number groups
*
* Default: `space`
*/
groupingSeparator?: string;
/**
* Separator between integer and fraction parts.
* Will be ignored if you set maximumFractionalDigits = 0
*
* Default: system separator
*/
fractionSeparator?: string;
/**
* Prefix before number.
*
* For example: if prefix = `$` input will be `$1,234.43`
*
* Default: `undefined`
*/
prefix?: string;
/**
* Suffix after number.
*
* For example: if suffix = ` EUR` input will be `1 234,43 EUR`
*
* Default: `undefined`
*/
suffix?: string;
/**
* Maximum length in integer part, exclude separators
* Maximum possible value is 36
*
* Default: `36`
*/
maximumIntegerDigits?: number;
/**
* Maximum length in fractional part
*
* Default: `2`
*/
maximumFractionalDigits?: number;
/**
* Minimum numeric value.
* It will be set to input if user enters value less than minValue
*/
minValue?: number;
/**
* Maximum numeric value.
* It will be set to input if user enters value greater than maxValue
*/
maxValue?: number;
}
qq限制
- 财产的最大可能价值
maximumIntegerDigits实值36
测试
为了装入由反应-内在-金钱输入提供的模拟器,请在 jest.config.json 中添加以下您在 joest 配置中:
"setupFiles": ["./node_modules/@alexzunik/react-native-money-input/jest/setup.js"]
捐款
见 贡献指南 学习如何为储存库和发展工作流程作出贡献.
许可证
麻省理工学院

