0

我是初學者,使用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的例子。 –

回答

0

以下是使用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