reactjs - 在 ReactJS 中更改 TextField 的线条颜色
问题描述
我正在使用 ReactJS 制作组件。因为我需要用不同的颜色自定义 TextInput 的线条颜色(一种用于成功验证,另一种用于失败验证)
import React, {Component} from 'react';
import {View, Text, StyleSheet, TextInput} from 'react-native';
import TextField from '@material-ui/core/TextField';
export default class CustomTextInput extends Component {
constructor(props) {
super(props);
this.state = {
name: '',
};
}
render() {
return (
<View>
<TextField
style={{margin: 10}}
id="standard-basic"
label="Standard"
error={false}
inputProps={{maxlength: 12}}
label="User Id"
/>
</View>
);
}
[![success validation][1]][1]
解决方案
首先,你可以使用material-ui
's error
prop. 如果您仍想更改颜色,则应使用material-ui
'swithStyles
或makeStyles
.
推荐阅读
- python - 如何检查字符串是否仅包含不可打印的字符和空格?
- javascript - 如何在一页上使用 Google Captcha for 2 Django Form
- android - 从 AnimatorVectorDrawable 只为一个目标设置动画
- javascript - SyntaxError:JSON.parse 中位置 0 处的 JSON 中的意外标记 u
- python - 使用 AWS Lambda 计算正在运行和停止的 Ec2 实例
- django - 从 Django 中的其他数据库中提取数据
- algorithm - 使用 RB 树的动态集
- database - 带有“和”“或”和否定条件的数据库查询
- sql - SQL 查询不检查 After 和 Clause
- html - 为什么 flexbox 没有按预期对齐项目