GithubHelp home page GithubHelp logo

Comments (1)

vkboo avatar vkboo commented on April 19, 2024 1

受控组件于非受控组件是针对表单元素来讲的,React是MVVM的库,数据(Model)的更新会通过ViewModel反映到视图(View)上,然而视图的更新并不会自动的映射到数据中,按照库默认的处理方式,则所有的表单就控件都是非受控组件,如果手动指定了表单元素的onChange事件,在事件函数中手动给相应的数据进行赋值,且这个值在绑定在表单的value/checked属性上,则这个表单元素就是受控组件。
简单的说受控于非受控的区别就是数据于视图之间是否互相绑定。按照React的**来说,一般我们在进行表单处理的时候都需要把组件处理成受控的,这样在做复杂的表单校验、提交数据的获取都会方便很多.

from react.

Related Issues (16)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.