<TextInput placeholder={"¥"} keyboardType={"decimal-pad"} selectionColor={'#4A90E2'} value={this.state.money} maxLength = {15} onChangeText={text => { if (text != null && text.length >=15) { Toast.show("总金额不能超过15位数",1000) }else { let newmoney = this.state.money try { let a =Number(text) if (isNaN(a)) { this.setState({ money: newmoney.trim() }) }else { this.setState({ money: text.trim() }) } }catch (e) { this.setState({ money: newmoney.trim() }) } } }}/>
写js 时输入框限制只能输入金额包含小数
最新推荐文章于 2022-03-17 16:55:49 发布