如何在reactJs.net中使用引导日期选择器

如何在reactJs.net中使用引导日期选择器

问题描述:

我是初学者,使用ReactJS。我正在使用ReactJs.Net(JSX)和MVC5。我想使用引导日期和时间选择器。我搜查了很多,但没有找到任何例子。我也搜索了http://reactjs.net/getting-started/tutorial.html。请帮助一个显示datepicker初始化的例子。这对我很有帮助。如何在reactJs.net中使用引导日期选择器

+0

有没有试图得到它的工作,当你遇到的任何具体问题?你采取了哪些步骤来进行调试? –

+0

我试图按照[链接](https://github.com/quri/react-bootstrap-datetimepicker)中的建议使用它。但它显示''没有定义。看来我需要配置一个使用datetime选择器的模板。这就是为什么我正在寻找一个JSX的例子。 –

以下是使用Bootstrap date-picker的ES6(使用BabelJS)示例。

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; 

工作例如:

enter image description here

参考:ReactJS froms