Is there any framework whose components interact with each other as easily as js method transfer?
First framework components communication is for the convenience of data interaction between modules, because the development of the framework is modular, modular development, tell a complete split into different components of the project, the view components, functional components, etc., and then form a page of interaction with complete function, the front three mainstream framework is a vue, react, React is being developed in versions 15 and 16. Angular has more versions, angularJS 1, Angularjs 2, AngularJS 4, AngularJS 5, AngularJS 6, AngularJS 8. Except that Angular1 is not componentized, all components are componentized, and component communication values are different in different versions.
In VUE, component communication is divided into nested components, parent to child, child to parent, sibling communication, and multi-component centralized data sharing. Is the most common of these values, parent – child components depends on the binding properties and props attribute, child components – the parent component depends on the binding events, $emit and the callback function, if you want to direct access to the current parent components and subcomponents can use ref attribute, and $parent to get father-son object directly, to obtain the data. The sibling component relies entirely on the $emit and $ON syntax for data transfer. In cases where components share too much data, vuEX is used for centralized management. Communication in Vue follows its own internal language specification compared to communication in JS. For the React framework, it is all about class object development. Inheriting the React declaration component syntax object, whether it is parent-child communication or parent-child communication, all depend on the binding of prop property on the component object to carry out state data transfer, because the carrier of data transfer in React is prop and state. So component communication is more dependent on these two objects. For centralized data management of multiple components, redux, Flux and other tools can be used to manage centralized data in a streamlined manner, making it more convenient to share component data. For Angular, componentized development was largely absent in version 1, and all data interactions were bridge over scope objects. After Version 2, Angular introduced componentized development, and parent-child component communication was entirely dependent on the rich core libraries provided by Angular, using decorators input, Output, Emit methods and attribute instructions in EventEmitter are used to complete parent-child and parent-child communication.
To sum up, the framework is developed based on JS, forming its own internal declaration specification, and component values are performed by its own internal API specification. Is to do two times for JS encapsulation or abstraction. Understand the framework of the API core language, component value is relatively easy to achieve.