javascript - ReactJS:更改表单中的占位符颜色
问题描述
我正在尝试更改占位符颜色以允许用户知道哪些字段是强制性的。
我有一个加载表单的 Index.js:
Content = props => {
const self = this
return(
<form
className="col-12 px-sm-0 px-xs-0"
onSubmit={e => e.preventDefault()}
onKeyPress={(e) => {
if (e.key === 'Enter') {
e.preventDefault(); //<===== This stops the form from being submitted
}
}}
>
<Inizio formName={FORM_NAME} />
和 Inizio.js
export default class Inizio extends Component
{
constructor(props)
{
super(props);
}
Fields = [
{
name: '$Anagraphics',
label: 'Dati anagrafici',
fields: [
{
name: 'Anagraphics.Surname',
col: ["lg-6", 'md-6', 'sm-12'],
label: "Cognome",
placeholder: "Cognome",
placeholderTextColor: "#6495ed",
required: true,
validate: FieldValidation.required,
component: Fields.Text,
normalize: value => utility.capitalizeEachWord(value)
},
你知道我怎样才能改变占位符的颜色吗?
解决方案
If you want to access a particular element of the array use Field[index].fields[index] and then the property name. In your case it would be Fields[0].fields[0].placeholderTextColor = '#value'.
推荐阅读
- ios - Swift/iOS - 如何使用一个范围/函数中的值并将其传递给另一个?
- python - Kivy 按钮不显示
- javascript - 使用 React 钩子在 Next.js 中只加载一次脚本?
- c++ - Poco::CryptoOutputStream 确定大小
- amazon-s3 - 在 React 上刷新网页时如何保持同一页面?
- algorithm - 为什么 DP 可以解决一些网格路径问题?
- php - Wordpress 如何从用户个人资料中显示 ACF 图像字段
- angular - 使用 select 动态更新两个数组
- crm - 当我在 zoho CRM 中使用 deluge 功能时,openUrl 不起作用
- javascript - 从向另一台服务器发出的请求下载文件而不将其保存在服务器上