A method for realizing linkage between multiple components based on expression
The expression-based method simplifies the linkage between multiple components, solves the problems of code complexity and maintenance difficulty in traditional methods, and achieves more efficient development and maintenance.
Patent Information
- Application Number
- CN202310420906.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-04-19
- Publication Date
- 2024-08-30
- Estimated Expiration
- 2043-04-19
AI Technical Summary
The traditional linkage method between multiple components is based on event mechanism or data binding, which results in high code complexity, low development efficiency, and high maintenance cost. It is especially difficult to maintain in complex applications.
Using an expression-based method, we obtain the relevant information of the basic component from the context information of the linkage component, write the operation content expression and parse its result value, embed it in the relevant information of the linkage component, and change the attribute values of the basic component to achieve Linkage, using Vue's reactive to create a global context object and pass it to the component, simplifying the configuration of the association between components.
It improves development efficiency, reduces development difficulty, improves code maintainability, enables more people to participate in application development, and reduces redundant code and maintenance costs.
Smart Images

Figure CN116627403B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of information technology, and in particular to a method for realizing linkage among multiple components based on expressions. Background Art
[0002] In the traditional development process, the function of linking multiple components is usually based on event mechanism or data binding.
[0003] The event mechanism refers to event binding between components. When an event of a component is triggered, other related components will perform corresponding operations and updates accordingly. When the number of events is large, it is easy to cause confusion and difficult maintenance of event handlers.
[0004] Data binding means binding the state of a component to data. When the state of a component changes, other related components will automatically update and operate according to the bound data. When the amount of data is large, performance bottlenecks and excessive memory usage are likely to occur.
[0005] Both event mechanisms and data binding require a lot of time and managers to manually write code, which reduces development efficiency. Moreover, manual code writing is prone to syntax errors, logical errors, etc., which extend the development cycle and increase project costs. Secondly, manual code writing will cause the platform to generate a large amount of redundant code, increase maintenance costs, and consume a lot of time and manpower costs. Especially when the application becomes more and more complex, it will become more difficult to manually write these codes. Summary of the invention
[0006] In order to solve the above problems, the present invention provides a method for realizing linkage between multiple components based on expressions, which can improve the flexibility of linkage between components, reduce the complexity of code, improve development efficiency and make maintenance and updating easier, and effectively solve the deficiencies in the prior art.
[0007] The present invention is implemented by the following technical scheme: a method for realizing linkage among multiple components based on expressions, comprising: in response to a selection operation on the linkage component, obtaining relevant information of the basic component from context information of the linkage component;
[0008] Opening the operation content expression of the linkage component in the parameter setting area of the component, writing the operation content of the relevant information about the basic component in the expression, and parsing according to the operation content written in the expression;
[0009] According to the result value of the calculated attribute, the expression result is run, and the result value is embedded into the relevant information of the linkage component;
[0010] According to the operation content of writing the relevant information about the basic component, the content of the relevant information of the basic component is changed, and the content of the context information is controlled to cause the attribute value of the linkage component to change.
[0011] As a preferred technical solution, the relevant information of the basic component obtained from the context information of the linkage component includes: attributes of the basic component.
[0012] As a preferred technical solution, the content of parsing according to the operation content written in the expression includes: converting the operation content expression into a function, running the function, and returning its result value as a calculated attribute.
[0013] As a preferred technical solution, in response to the selection operation on the linkage component, a front-end device is applied to present a graphical user interface, on which a component list area, a canvas area and a parameter setting area are displayed; the required components are selected in turn from the component list area and dragged to the canvas area, and multiple components are displayed on the canvas area, including: at least one basic component and one linkage component.
[0014] As a preferred technical solution, the operation content expression: the parameter setting area should include configuration operations on the attribute values of the basic components and linkage components, and the configuration operations include: changing the attribute values of the attributes; the method of changing the attribute values can support the input of the expression content.
[0015] As a preferred technical solution, it also includes:
[0016] When the program is initialized, Vue's reactive is used to create a global context object, and the global context object is passed to all components as a property value so that global information can be obtained when obtaining the component context.
[0017] As a preferred technical solution, before writing the information about the basic component, the method further includes:
[0018] The field information of the basic component and the global information of the page component are obtained in the expression; the steps of obtaining the field information of the basic component and the global information of the page are specifically as follows:
[0019] Search upward from the linkage component, and if a local context object is passed in the upper component, traverse all subset components of the upper component as local context attributes;
[0020] All components are traversed, and the context attributes of the parent component and all its subsets are excluded as global context attributes.
[0021] As a preferred technical solution, the method further includes:
[0022] When there are multiple attributes on the linkage component for expression linkage, all expression result values must be encapsulated by attributes. The specific steps are as follows:
[0023] Put the result value of the corresponding calculated property into an object;
[0024] The key in the object is used as the attribute name and the value is used as the attribute value to be passed to the attributes of the linkage component.
[0025] The beneficial effects of the present invention are: 1. Improve development efficiency: When realizing linkage between multiple components, the relationship between components set by developers is some complex logical operations, such as conditional statements, loop statements, etc. Expression language is a lightweight programming language with simple and easy-to-understand syntax. Using expression language to express these relationships does not require writing a lot of repetitive code, and time and energy can be invested in other aspects of the application, thereby accelerating the development process;
[0026] 2. Reduce development difficulty: Traditional application development requires developers to master multiple programming languages and technologies, while the platform based on expressions to achieve linkage between multiple components only requires developers to understand basic expression syntax and interface operations, without having to deeply understand the underlying technical details. This allows more people to participate in application development;
[0027] 3. Better maintainability: Using expression linkage components can present the linkage logic in an easy-to-understand way, making the code clearer, easier to read and understand, and improving the maintainability of the application. BRIEF DESCRIPTION OF THE DRAWINGS
[0028] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0029] Figure 1 The present invention is a flowchart of the steps of a method for realizing linkage between multiple components based on expressions. DETAILED DESCRIPTION
[0030] All features disclosed in this specification, or steps in all methods or processes disclosed, except mutually exclusive features and / or steps, can be combined in any manner.
[0031] Any feature disclosed in this specification (including any additional claims, abstract and drawings), unless otherwise stated, may be replaced by other equivalent or alternative features with similar purposes. That is, unless otherwise stated, each feature is only an example of a series of equivalent or similar features.
[0032] In the description of the present invention, it is necessary to understand that the terms "one end", "the other end", "outside", "upper", "inside", "horizontal", "coaxial", "center", "end", "length", "outer end" and the like indicate orientations or positional relationships based on the orientations or positional relationships shown in the accompanying drawings, and are only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as a limitation on the present invention.
[0033] In addition, in the description of the present invention, “plurality” means at least two, for example, two, three, etc., unless otherwise clearly and specifically defined.
[0034] Terms such as "upper", "above", "lower", "below", etc. used in the present invention to indicate spatial relative positions are used for the purpose of convenience to describe the relationship of one unit or feature relative to another unit or feature as shown in the accompanying drawings. Terms of spatial relative position may be intended to include different orientations of the device in use or operation in addition to the orientation shown in the drawings. For example, if the device in the figure is turned over, the unit described as being "below" or "beneath" other units or features will be located "above" the other units or features. Therefore, the exemplary term "below" can encompass both the above and below orientations. The device may be oriented in other ways (rotated 90 degrees or other orientations), and the spatially related descriptors used herein interpreted accordingly.
[0035] In the present invention, unless otherwise clearly specified and limited, the terms "disposed", "socketed", "connected", "through", "plugged" and the like should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral one; it can be a mechanical connection or an electrical connection; it can be a direct connection or an indirect connection through an intermediate medium, it can be the internal connection of two elements or the interaction relationship between two elements, unless otherwise clearly defined. For ordinary technicians in this field, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.
[0036] like Figure 1 As shown, the method for realizing linkage among multiple components based on expressions described in the present invention includes:
[0037] In response to a selection operation on the linkage component, obtaining relevant information of the basic component from context information of the linkage component;
[0038] When the program is initialized, Vue's reactive is used to create a global context object, and the global context object is passed to all components as a property value.
[0039] Before writing the information about the basic component, the method for realizing linkage among multiple components based on expressions further includes:
[0040] Get the field information of the basic component and the global information of the page component in the expression;
[0041] The steps to obtain the field information of the basic components and the global information of the page are as follows:
[0042] Search upward from the linked component, and traverse all subset components in the parent component that pass the local context object as the local context attribute;
[0043] Traverse all components and exclude the context attributes of the parent component and all its subsets as global context attributes;
[0044] Specifically, the process of passing the global context object as a property value to all components is as follows:
[0045] When the page is initialized, use reactive to create global object variables, package the global variables into a global context object, and pass it to the rendering engine;
[0046] At the same time, the configuration information of the page components is passed to the rendering engine;
[0047] The packaging method used is to create an object and point the data attribute in the object to the created global object variable. The rendering engine will instantiate the core class of the component according to the passed component configuration information and pass the passed context object to the core class. The core class of the component is divided into the basic core class and the form core class. The form core class inherits from the basic core class.
[0048] The method for realizing linkage among multiple components based on expressions described in the present invention further includes:
[0049] The operation content of the related information about the basic component is written into the expression;
[0050] Parse according to the operation content written in the expression;
[0051] Running the expression result and embedding the result value into the related information of the linkage component;
[0052] The specific steps for parsing the operation content written into the expression are:
[0053] Convert the operation content expression into a function according to the preset logic;
[0054] Return the function result value as a calculated property;
[0055] Among them, when multiple attributes on the linkage component are linked by expressions, all expression result values are encapsulated as attributes;
[0056] Among them, the specific steps of attribute encapsulation are:
[0057] Put the result value of the corresponding calculated property into an object;
[0058] The key of the object is used as the attribute name, and the value is used as the attribute value passed to the attributes of the linkage component.
[0059] Specifically, when the basic core class is initialized, the component properties described by the expression method in the component configuration information are passed to the expression processor. The expression processor processes the expression into a functional form through a specific logical method. The expression processor converts the passed expression characters into a function, sets the context object of the function to the context object of the current component, and then packages the function into a calculated property through Vue's computed and returns it to the core class.
[0060] The base core class combines all the properties of the component into an object and retains it in the properties of the base core class. When the form core class is initialized, it extracts the fields in the component configuration information and the context object in the core class and packages them into a writable calculated property through Vue's computed.
[0061] The writable computed properties include two functions: get function and set function; the get function mainly retrieves and returns the value from the context object through the field; the set function changes the attribute value in the context object through the field. The rendering warning starts rendering the component after instantiating the core class of the component, and uses the key value of the object composed of all the attributes in the core class as the attribute name, and the value is passed to the rendering component as the attribute value.
[0062] The method for realizing linkage among multiple components based on expressions described in the present invention further includes:
[0063] A front-end device used to present a graphical user interface;
[0064] The graphical user interface displays a component list area, a canvas area, and a parameter setting area;
[0065] The canvas area includes:
[0066] Select the required components from the component list area in turn and drag them to the canvas area;
[0067] The canvas area displays at least one basic component and one linkage component;
[0068] The parameter setting area should include configuration operations for the attribute values of basic components and linkage components, including:
[0069] Change the property value of an attribute;
[0070] Methods for changing property values by entering in expression content;
[0071] The method for realizing linkage among multiple components based on expressions described in the present invention further includes:
[0072] The basic component changes the relevant information according to the preset operation content of the relevant information about the basic component;
[0073] The change in the context information content causes the attribute value of the linkage component to change;
[0074] Specifically, when the value bound to the basic component changes, the set function in the writable calculated property in the form core class will be triggered. The set function will cause the attribute value in the context object to change, which in turn triggers the attribute value that has been packaged into the calculated property to change. The change in the calculated property causes the change of the attribute combination object in the core class; the rendering engine will again pass the key value of the attribute object as the attribute name and the value as the attribute value to the rendering component, and the linked components will therefore change in a linked manner.
[0075] The core of the method for realizing linkage between multiple components based on expressions described in the present invention is to design an expression engine, which is responsible for parsing the expression syntax and operators input by the user and can process various types of data; the linkage function between components is realized through the expression engine, for example, when the user enters data in the input box. The expression engine can be triggered to calculate the corresponding results based on the data input by the user, and pass the results to other components to update their status and display content. The specific advantages of the present invention are:
[0076] 1. Improve development efficiency: When implementing linkage between multiple components, developers need to perform some complex logical operations to set the relationship between components, such as conditional statements, loop statements, etc. Expression language is a lightweight programming language with simple and easy-to-understand syntax. Using expression language to express these relationships does not require writing a lot of repetitive code, and time and energy can be invested in other aspects of the application, thereby accelerating the development process;
[0077] 2. Reduce development difficulty: Traditional application development requires developers to master multiple programming languages and technologies, while the development platform based on expressions to achieve linkage between multiple components only requires developers to understand basic expression syntax and interface operations, without having to deeply understand the underlying technical details. This allows more people to participate in application development.
[0078] 3. Better maintainability: Using expression linkage components can present the linkage logic in an easy-to-understand way, making the code clearer, easier to read and understand, and improving the maintainability of the application.
[0079] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any changes or substitutions that are not conceived through creative work should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention should be based on the protection scope defined in the claims.
Claims
1. A method for realizing linkage among multiple components based on expression, characterized in that: include: In response to a selection operation on a linkage component, obtaining relevant information of a basic component from context information of the linkage component; Opening the operation content expression of the linkage component in the parameter setting area of the component, writing the operation content of the relevant information about the basic component in the expression, and parsing according to the operation content written in the expression; According to the result value of the calculated attribute, the expression result is run, and the result value is embedded into the relevant information of the linkage component; According to the operation content of writing the relevant information about the basic component, the content of the relevant information of the basic component is changed, and the content of the context information is controlled to cause the attribute value of the linkage component to change; The relevant information of the basic component obtained from the context information of the linkage component includes: the attributes of the basic component; Parsing is performed according to the operation content in the written expression, including: converting the operation content expression into a function, running the function, and returning its result value as a calculated attribute; Also includes: When the program is initialized, use Vue's reactive to create a global context object, and pass the global context object as a property value to all components so that global information can be obtained when obtaining component context information; The process of passing the global context object as a property value to all components is as follows: When the page is initialized, use reactive to create global object variables, package the global object variables into global context objects, and pass them to the rendering engine; At the same time, the configuration information of the page components is passed to the rendering engine; The packaging method used is to create an object and point the data attribute in the object to the created global object variable. The rendering engine instantiates the core class of the component according to the passed component configuration information and passes the passed global context object to the core class. The core class of the component is divided into the basic core class and the form core class. The form core class inherits from the basic core class. Before writing the information about the basic component, the method further includes: In the expression, the field information of the basic component and the global information of the page component are obtained; the steps of obtaining the field information of the basic component and the global information of the page component are specifically as follows: Search upward from the linkage component, and if a local context object is passed in the upper component, traverse all subset components of the upper component as local context attributes; All components are traversed, and the context object after excluding the parent component and all its subset components is used as the global context attribute.
2. The method for realizing linkage among multiple components based on expression according to claim 1, characterized in that: In response to a selection operation on the linkage component, a front-end device is applied to present a graphical user interface, where a component list area, a canvas area and a parameter setting area are displayed on the graphical user interface; Select the required components from the component list area in turn and drag them to the canvas area. Multiple components are displayed on the canvas area, and the multiple components include: at least one basic component and one linkage component.
3. The method for realizing linkage among multiple components based on expression according to claim 1, characterized in that: The operation content expression includes: including configuration operations on the attribute values of the basic component and the linkage component in the parameter setting area, and the configuration operations include: changing the attribute values of the components; the method of changing the attribute values can support the input of the expression content.
4. The method for realizing linkage among multiple components based on expression according to claim 1, characterized in that: The method further comprises: When there are multiple attributes on the linkage component for expression linkage, all expression result values are attribute encapsulated. The specific steps are as follows: Put the result value of the corresponding calculated property into an object; The key in the object is used as the attribute name and the value is used as the attribute value to be passed to the attributes of the linkage component.
Citation Information
Patent Citations
Data linkage method and system
CN110020376A
Method and device for intra-tableand inter-table linkage calculation of report and electronic equipment
CN112861492A
