Two-way data binding mechanism What are potential drawbacks

  • One-way data binding: first templates written, and then the template data (background data may come from) integrated together to form the HTML code, the HTML code inserted into the document and then the stream
    -way data binding disadvantages: HTML code generator after it is difficult to change, if there is new data before it is necessary to remove the HTML code, so that new data template and re-integration into the document flow in

  • Two-way data binding: two-way data binding between the model and view, modify user will be automatically synchronized to the view of the data model to the same, if the value of the data model changes, will immediately sync to view go
    way data binding advantages: those CRUD (Create, Retrieve, Update, Delete) operation without the need for one-way data binding and
    two-way data binding most often application scenarios: a form, when the user completes the input front page, without any action, we've got the user data stored in the data model in the
    current, two-way data binding framework to achieve the front end of the main AngularJS, VueJS (to implement data monitoring individual by introducing vuex) and other
    two-way data binding shortcomings : Angular implement the principle of two-way binding is dirty to be examined by $ watch, if a large number of checks would be inefficient

  • One-way and two-way data binding data binding scenarios:
    the advantages of a one-way binding is the appropriate way data flow can bring the benefits of doing so is that all state changes can be recorded, tracked, status changes by manually calling notification, the source of easily traceable, there is no "black-box operation." While the component has only one data inlet and outlet, so that more intuitive and easier to understand the program, facilitate maintainability applications. The disadvantage is that the amount of code is increased correspondingly, the data transfer process becomes long, so there are many similar boilerplate code. And because of the stringent requirements (single global store) on the application of state independently managed, in dealing with many of the local state of the scene (such as user input to interact more "rich form" applications), it will seem long-winded and tedious.
    The advantages of two-way binding is more in the form of interactive scene, a large number of independent business will simplify the code. The disadvantage is that due to the "black-box", we can not track changes in the local state (although in most cases we do not care), too many potential behavior also increases the difficulty debug the error. At the same time due to the component data source entry may change becomes more than a novice player can easily be confused disorder data flow direction, if we lack some "control" means, and finally it is easy to operate because of an error caused by application of an avalanche.

Summary: We want a reasonable selection of one-way data binding mechanism through their own business scenarios

Guess you like

Origin www.cnblogs.com/ButterflyEffect/p/10942947.html