CN-122019905-A - Page rendering method and device, electronic equipment and storage medium
Abstract
The application discloses a page rendering method, a page rendering device, electronic equipment and a storage medium, and relates to the technical field of front-end development. Responding to the instantiation of a target component, determining a routing component of the page where the target component is located through the routing information of the page where the target component is located, traversing a component tree in the direction of the routing component by taking the target component as a starting position when the target component is a sub-component of the routing component, searching at least one ancestor component with preset reference configuration, and then rendering the target component according to the preset reference configuration corresponding to the ancestor component with the highest hierarchy. Therefore, the components at different levels in the component tree can be uniformly rendered according to the preset reference configuration set by the ancestor component with the highest level in the component tree during rendering, so that the problem of component rendering distortion caused by reference inheritance confusion among the components is avoided, and the consistency of page rendering is further ensured.
Inventors
- ZENG YONG
Assignees
- 佳都科技集团股份有限公司
- 广州佳都智通科技有限公司
- 广东华之源信息工程有限公司
- 广州华佳软件有限公司
- 广州佳都城轨智慧运维服务有限公司
Dates
- Publication Date
- 20260512
- Application Date
- 20251216
Claims (10)
- 1. A method of page rendering, the method comprising: Responding to instantiation of a target component, and acquiring route information of a page where the target component is located; searching a routing component of a page where the target component is located based on the routing information; If the target component is a sub-component of the routing component, traversing a component tree in the direction of the routing component by taking the target component as a starting position, and searching at least one ancestor component with preset reference configuration, wherein the component tree represents the hierarchical relationship among different components in a plurality of pages; And in the searched at least one ancestor component, rendering the target component according to the preset reference configuration corresponding to the ancestor component with the highest hierarchy.
- 2. The method of claim 1, wherein if the target component has an initial baseline configuration, the method further comprises: if the target component is the routing component, rendering the target component based on the initial reference configuration; and/or if the target component is a sub-component of the routing component, and the target component is taken as a starting position, traversing the component tree towards the routing component direction, and if an ancestor component with a preset reference configuration is not obtained, rendering the target component based on the initial reference configuration.
- 3. The method of claim 2, wherein when a plurality of ancestor components are found and the preset reference configuration for each ancestor component has a preset weight value, the method further comprises: if at least part of preset reference configurations are different in preset weight values, rendering the target assembly according to the preset reference configuration corresponding to the preset weight value with the largest value; And if the preset weight values of the preset reference configurations are the same, selecting the preset reference configuration corresponding to the ancestor component with the highest hierarchy in the component tree, and rendering the target component.
- 4. A method according to claim 3, wherein the initial reference configuration of the target component has an initial weight value, the method further comprising: Searching a first preset weight value with the largest value in the preset weight values of the preset reference configurations; If the initial weight value is smaller than or equal to the first preset weight value, rendering the target component according to preset reference configuration corresponding to the first preset weight value; and if the initial weight value is larger than the first preset weight value, rendering the target component based on the initial reference configuration.
- 5. The method of claim 1, wherein when the target component is located on a plurality of different pages, at least some of the pages correspond to different routing information, the method further comprising: Aiming at one target page where the target component is located, acquiring target routing information corresponding to the target page; Searching a target routing component of the target page based on the target routing information; and if the target routing component has the preset reference configuration, rendering the target component based on the preset reference configuration of the target routing component.
- 6. The method of claim 5, wherein the method further comprises: If the target routing component does not have the preset reference configuration, traversing a component tree towards the parent routing component direction of the target component by taking the target routing component as a starting position, and searching a routing component with the preset reference configuration as a reference routing component; Rendering the target component based on a preset reference configuration of the reference routing component.
- 7. The method according to claim 1, wherein the method further comprises: If the page where the target component is located comprises at least one sub-page and the target component is located on one of the sub-pages, obtaining a component sub-tree of the sub-page, wherein the component sub-tree represents the hierarchical relationship among different components in the same sub-page; And if the target component has the initial reference configuration and the target component is the root node of the component subtree, rendering each component in the component subtree according to the initial reference configuration of the target component.
- 8. A page rendering apparatus, the apparatus comprising: the route information acquisition module is used for responding to the instantiation of the target component and acquiring the route information of the page where the target component is located; the route component searching module is used for searching a route component of a page where the target component is located based on the route information; The ancestor component confirming module is used for traversing a component tree in the direction of the routing component by taking the target component as a starting position if the target component is a sub-component of the routing component, searching at least one ancestor component with preset reference configuration, and representing the hierarchical relationship among different components in a plurality of pages by the component tree; And the rendering reference determining module is used for rendering the target component according to the preset reference configuration corresponding to the ancestor component with the highest hierarchy in the searched at least one ancestor component.
- 9. An electronic device, comprising: a memory and a processor communicatively coupled to each other, the memory having stored therein computer instructions, the processor executing the computer instructions to perform the page rendering method of any of claims 1 to 7.
- 10. A computer-readable storage medium having stored thereon computer instructions for causing a computer to perform the page rendering method of any one of claims 1 to 7.
Description
Page rendering method and device, electronic equipment and storage medium Technical Field The invention relates to the technical field of front-end development, in particular to a component benchmark determining method, a component benchmark determining device, electronic equipment and a storage medium. Background With the continuous increase of the complexity of front-end applications, the front-end pages generally adopt a componentized development mode, i.e., by dividing an interface into a plurality of reusable and nestable components, so as to improve development efficiency and later maintainability. Currently, in some technologies, the rendering benchmarks of components are mainly transferred in a manner of relying on injection, that is, the rendering benchmarks of parent components are inherited to child components, so that the rendering benchmarks are configured. However, this approach is prone to problems of component rendering distortion caused by rendering reference inheritance errors when faced with complex component nesting structures. Improvements are needed. Disclosure of Invention The invention provides a component reference determining method, a device, electronic equipment and a storage medium, which at least solve the problem of component rendering distortion caused by rendering reference inheritance errors in the related art. In a first aspect, the present invention provides a page rendering method, including: Responding to the instantiation of the target component, and acquiring the route information of the page where the target component is located; Searching a routing component of a page where a target component is located based on the routing information; If the target component is a sub-component of the routing component, traversing a component tree in the direction of the routing component by taking the target component as a starting position, searching at least one ancestor component with preset reference configuration, and representing the hierarchical relationship among different components in a plurality of pages by the component tree; and in the searched at least one ancestor component, rendering the target component according to the preset reference configuration corresponding to the ancestor component with the highest hierarchy. In a second aspect, the invention provides a page rendering device, which comprises a route information acquisition module, a first module and a second module, wherein the route information acquisition module is used for responding to the instantiation of a target component and acquiring the route information of a page where the target component is positioned; the route component searching module is used for searching a route component of a page where the target component is located based on the route information; The ancestor component confirming module is used for traversing a component tree in the direction of the routing component by taking the target component as a starting position if the target component is a sub-component of the routing component, searching at least one ancestor component with preset reference configuration, and representing the hierarchical relationship among different components in a plurality of pages by the component tree; And the target component rendering module is used for rendering the target component according to the preset reference configuration corresponding to the ancestor component with the highest hierarchy in the searched at least one ancestor component. In a third aspect, the present invention provides an electronic device, including a memory and a processor, where the memory and the processor are communicatively connected to each other, and the memory stores computer instructions, and the processor executes the computer instructions, thereby executing the page rendering method according to the first aspect or any implementation manner corresponding to the first aspect. In a fourth aspect, the present invention provides a computer-readable storage medium having stored thereon computer instructions for causing a computer to perform the page rendering method of the first aspect or any one of its corresponding embodiments. In a fifth aspect, the present invention provides a computer program product comprising computer instructions for causing a computer to perform the page rendering method of the first aspect or any of its corresponding embodiments. In some embodiments of the present application, in response to instantiation of a target component, determining a routing component of a page where the target component is located according to routing information of the page where the target component is located, traversing a component tree in a direction of the routing component by using the target component as a starting position when the target component is a sub-component of the routing component, searching for at least one ancestor component having a preset reference configuration, and then rendering the target