【发布时间】:2018-05-14 13:08:00
【问题描述】:
我正在使用 react-day-picker 字段 (https://react-day-picker.js.org/)。我想定制它。我已经去了 react-day-picker/lib/style.css 并使用了颜色、字体大小等。但问题是,我无法更改占位符样式本身!我已经尝试了一切,基本上我想做的是显示 "Hello" 并制作 红色背景 而不是 YYYY-MD 和白色背景。请帮忙。这就是我现在所拥有的: https://ibb.co/nGgCwJ
我的 .js 代码:
import React, {Component} from 'react';
import DayPickerInput from 'react-day-picker/DayPickerInput';
import 'react-day-picker/lib/style.css';
class DateP extends Component {
constructor(props) {
super(props);
this.handleDayChange = this.handleDayChange.bind(this);
this.state = {
selectedDay: undefined
};
}
handleDayChange(day) {
this.setState({ selectedDay: day });
}
render() {
const { selectedDay} = this.state;
return (
<div>
{selectedDay && <h3>Day: {selectedDay.toLocaleDateString()}</h3>}
{!selectedDay && <h3>Date Picker</h3>}
<DayPickerInput
onDayChange={this.handleDayChange}
/>
</div>
);
}
}
export default DateP;
【问题讨论】:
-
?你试过用
input[placeholder] -
@HarishSoni 在 React 中不能这样工作......
-
你可以使用 CSS。
-
如果您需要进一步的帮助,请告诉我。
标签: javascript reactjs datepicker