如何在 reactJs.net 中使用 bootstrap 日期选择器
How can I use bootstrap datepicker in reactJs.net
我是 ReactJS 的初学者。我在 MVC5 中使用 ReactJs.Net (JSX)。我想使用 bootstrap 日期和时间选择器。我搜索了很多但没有找到任何例子。我还在 http://reactjs.net/getting-started/tutorial.html 上搜索过。请帮助显示日期选择器初始化的示例。这对我有很大帮助。
这里是一个ES6(使用BabelJS)使用Bootstrap的例子date-picker
。
Declaimer:我没有使用过 ReactJS.net,但使用过 ReactJS
"use strict";
import React, { PropTypes } from 'react';
class Calender extends React.Component {
constructor(props) {
super(props);
this.state = {
date : "2016-01-15T01:06"
};
}
render() {
return (
<input type="datetime-local" ref={(date) => {this.dateRef = date;}} value={this.state.date} onChange={this._onDateChange.bind(this)}/>
);
}
_onDateChange(e) {
let state = this.state;
state['date'] = e.target.value;
// Or (you can use below method to access component in another method)
state['date'] = this.dateRef.value;
this.setState(state);
}
}
export default Calender;
工作示例:
.
我是 ReactJS 的初学者。我在 MVC5 中使用 ReactJs.Net (JSX)。我想使用 bootstrap 日期和时间选择器。我搜索了很多但没有找到任何例子。我还在 http://reactjs.net/getting-started/tutorial.html 上搜索过。请帮助显示日期选择器初始化的示例。这对我有很大帮助。
这里是一个ES6(使用BabelJS)使用Bootstrap的例子date-picker
。
Declaimer:我没有使用过 ReactJS.net,但使用过 ReactJS
"use strict";
import React, { PropTypes } from 'react';
class Calender extends React.Component {
constructor(props) {
super(props);
this.state = {
date : "2016-01-15T01:06"
};
}
render() {
return (
<input type="datetime-local" ref={(date) => {this.dateRef = date;}} value={this.state.date} onChange={this._onDateChange.bind(this)}/>
);
}
_onDateChange(e) {
let state = this.state;
state['date'] = e.target.value;
// Or (you can use below method to access component in another method)
state['date'] = this.dateRef.value;
this.setState(state);
}
}
export default Calender;
工作示例: