Comments (1)
受控组件于非受控组件是针对表单元素来讲的,React是MVVM的库,数据(Model)的更新会通过ViewModel反映到视图(View)上,然而视图的更新并不会自动的映射到数据中,按照库默认的处理方式,则所有的表单就控件都是非受控组件,如果手动指定了表单元素的onChange事件,在事件函数中手动给相应的数据进行赋值,且这个值在绑定在表单的value
/checked
属性上,则这个表单元素就是受控组件。
简单的说受控于非受控的区别就是数据于视图之间是否互相绑定。按照React的**来说,一般我们在进行表单处理的时候都需要把组件处理成受控的,这样在做复杂的表单校验、提交数据的获取都会方便很多.
from react.
Related Issues (16)
- 什么是高阶组件?你在工作中是如何应用的? HOT 1
- 创建React动画有哪些方式?
- 你对immutable有了解吗?它有什么作用? HOT 2
- 你知道的React性能优化有哪些方法? HOT 1
- 你对Fiber了解多少? HOT 1
- React Hooks工作原理?
- React和Vue的DOM-DIFF对比?
- useImperativeHandle 使用场景和原理是什么?
- 展示组件(Presentational component)和容器组件(Container component)之间有何不同?
- React 中 refs 的作用是什么?
- (组件的)状态(state)和属性(props)之间有何不同?
- React Context的优缺点
- 谈谈你对Redux的了解和应用吧
- 如何做国际化
- React为什么要搞Hooks,它帮我们解决了哪些问题?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react.