Hướng dẫn ReactJS ReactJS tutorial (p8) Bài 8: ReactJs Tạo Forms trong React

4 227 5
Hướng dẫn ReactJS   ReactJS tutorial (p8) Bài 8: ReactJs  Tạo Forms trong React

Đang tải... (xem toàn văn)

Thông tin tài liệu

Trong bài này, chúng ta sẽ tìm hiểu cách tạo form để nhập dữ liệu trong React. Simple Example Trong ví dụ sau đây chúng ta sẽ khởi tạo 1 input form với value= {this.state.data}, dữ liệu trong form là state của component. Và chúng ta sẽ update state khi chúng ta thay đổi value trong input. Chúng ta sẽ sử dụng sự kiện onChange đê kiểm tra sự thay đổi trong input và update lại state, không dong dài nữa chúng ta cùng xem ví dụ để hiểu rõ hơn nào. App.js

... chưa cần quan tâm đến đâu, nói rõ series React nâng cao Index.js import React from 'react' ; import ReactDOM from 'react- dom'; import App from './App.jsx'; ReactDOM.render(, document.getElementById('app'));... {this.props.myDataProp} ); } } export default App; Index.js import React from 'react' ; import ReactDOM from 'react- dom'; import App from './App.jsx'; ReactDOM.render(, document.getElementById('app'));... dễ hiểu ví dụ này) Các bạn xem kĩ ví dụ này, sau lại đề cập đến App.js import React from 'react' ; class App extends React. Component { constructor(props) { super(props); this.state = { data: 'Initial

Ngày đăng: 03/04/2018, 17:29

Từ khóa liên quan

Mục lục

  • Bài 8: ReactJs - Tạo Forms trong React

    • Simple Example 

    • Complex Example 

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan