Single example implementation method based on Element Tooltip text prompt
By importing and registering the Element UI component library in a Vue.js project <el-tooltip> The component creates a unified entry node, which, combined with custom logic and event handling, solves the memory leak and display control problems caused by frequent tooltip creation. It enables flexible and maintainable tooltip display and hiding, improving the user experience.</el-tooltip>
Patent Information
- Application Number
- CN202410907070.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-08
- Publication Date
- 2024-11-15
AI Technical Summary
The original Element solution resulted in memory leaks and slow page loading due to frequent creation and destruction of tooltips. Furthermore, it could not dynamically control the display of tooltips based on whether the content overflowed the container, leading to redundant configurations and inconsistent display styles.
Register by importing the Element UI component library into your Vue.js project.
It improves component maintainability and user experience, avoids page lag caused by too many DOM elements, reduces redundant configuration, enables flexible display and hiding of tooltips, and improves response speed and user interaction.
Smart Images

Figure CN118963740A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of prompt information display when a mouse is hovering, and more specifically, the present invention relates to a singleton implementation method based on Element Tooltip text prompt. Background Art
[0002] Element is a front-end open source component library based on Vue, which is used by a large number of front-end developers. With the continuous development of Internet applications, users have higher and higher requirements for interactive experience. Therefore, the use of Tooltip has become an important trend in front-end development. Tooltip text prompts are widely used in scenarios such as information explanation / supplementation, guiding users, enhancing accessibility and improving user experience.
[0003] In the original Element solution, each time the Tooltip is triggered, the DOM element will be recreated. The accumulation of a large number of DOM elements will increase the memory usage and rendering burden of the page, causing the page loading speed to slow down or even cause the page to freeze. Frequent creation and destruction of DOM elements will cause memory leaks. As DOM elements accumulate, the structural complexity of the page will also increase, making it more difficult to maintain the page, leading to layout problems and style conflicts.
[0004] In the original Element solution, the Tooltip display and hiding can only be controlled by the disabled switch. The display of the Tooltip cannot be dynamically controlled based on whether the content overflows the container. Multiple parts depend on the same Tooltip instance, and there are a lot of redundant configurations and the display styles are too uniform. Summary of the invention
[0005] The present invention aims at the technical problems existing in the prior art and provides a singleton implementation method based on Element Tooltip text prompt to solve the problems raised in the above background technology.
[0006] The technical solution of the present invention to solve the above technical problem is as follows: a single-case implementation method based on Element Tooltip text prompt, comprising the following steps:
[0007] S101. Introduce the Element UI component library in the Vue.js example project, using <el-tooltip>The component creates a unified entry node;
[0008] S102. Use the getTooltipVm function to receive parameters, and use the refName parameter to obtain the corresponding Vue.js instance project <el-tooltip>The instance of the component, the getTooltipVm function returns the obtained <el-tooltip>An instance of a component;
[0009] S103. Arrange onmouseover event listeners and onmouseout event listeners to capture mouse entry and removal events, use the onEvent function to bind the focus event handler to a specific DOM element and execute the corresponding logic, and use the setReference function to receive the parameters of the current element that triggers the mouse entry event for the mouseenter event;
[0010] S104. Create a temporary DOM element and receive the text string parameter for which the text length needs to be calculated through the caclTextWidth function, and receive the DOM element parameter related to the width that needs to be calculated through the calcWidth function according to the temporary DOM element;
[0011] S105. Call the method inside Element to listen to and process the events of Element UI components and complete <el-tooltip>Component display logic and hiding logic;
[0012] In a preferred embodiment, in S101, the Element UI component library is introduced into the Vue.js example project, and registered in the global entry file of main.js before the Vue.js example project is created. <el-tooltip>Components, using <el-tooltip>Components create a unified entry node through <el-tooltip>The component wraps the tooltip element and passes the tooltip element's content as a child component to <el-tooltip>Component.
[0013] Furthermore, import the blm-tooltip.js file and include custom logic, style, and behavior, and configure it in the global entry file <el-tooltip>Component and set the ref attribute to reference it. <el-tooltip>The component binds the unified configuration properties of tooltipOpt and passes the unified configuration properties of tooltipOpt to <el-tooltip>Component, register the custom directive through the directives property in the global configuration object of the Vue.js project instance, use the v-blm-tooltip directive to activate the custom directive and use it in the el-input element.
[0014] In a preferred embodiment, in S102, the getTooltipVm function is used to receive parameters, including a vnode parameter for a virtual node, a refName parameter for a reference name, and an option object. The Vue.js instance project is obtained by using the vnode parameter inside the getTooltipVm function, and the refName parameter is used to obtain the corresponding Vue.js instance project. <el-tooltip>Component instance, additional options parameter <el-tooltip>The component instance performs content settings and location settings to check the global entry file configuration <el-tooltip>The existence of global configuration items in the component determines the type of the refName parameter to obtain the root instance based on <el-tooltip>The component instance is referenced by setting the ref attribute, and the corresponding refName parameter of the root instance is searched. <el-tooltip>The instance of the component, the getTooltipVm function returns the obtained <el-tooltip>An instance of a component.
[0015] In a preferred embodiment, in S103, the onEvent function is used to bind the mouse event processing to a specific DOM element, and the corresponding logic is executed when the mouse event occurs, and the onmouseover event listener and the onmouseout event listener are arranged to capture the events of the mouse moving into and removing the element. When the mouse moves into the element, the setReference function is called to set the reference element and display it. <el-tooltip>Component, hide when the mouse moves out of the element <el-tooltip>The component uses the onEvent function to bind the focus event processing to a specific DOM element and executes the corresponding logic when the focus event occurs. When the element gains focus, the focus event is triggered and the focus-related logic is processed by calling the handleFocus function. When the element loses focus, the blur event is triggered and the popper.handleBlur function is called to process the pop-up related logic. When the element is clicked, the click event is triggered and the popper.removeFocusing function is called to remove the focus state.
[0016] Furthermore, for the mouseenter event, the setReference function is used to receive the parameters of the element that currently triggers the mouse move event, and the current element is set to <el-tooltip>A reference object to the component, according to the configuration settings <el-tooltip>The content and position properties of the component are dynamically adjusted according to the position of the mouse event <el-tooltip>The position of the component is used to ensure that the reference element is not obscured and the popper.show() method is called to display it. <el-tooltip>Component.
[0017] In a preferred embodiment, in S104, the parameter of the text string whose text length needs to be calculated is received through the caclTextWidth function, a temporary DOM element is created, the style of the temporary DOM element is set, the incoming text string is set as the textContent attribute of the temporary DOM element, the temporary DOM element is added to the document and the text length is obtained through the clientWidth attribute of the temporary DOM element. After obtaining the text length, the temporary DOM element is removed and the text length is returned as the return value of the function.
[0018] Furthermore, the calcWidth function receives the parameter of the DOM element whose width needs to be calculated, and calls the caclTextWidth function to calculate the width of the text content. When the passed-in DOM element is a container element, the width of the container is directly obtained through the clientWidth attribute of the element, and the width of the text content is assembled into an object and returned as the return value of the function.
[0019] In a preferred embodiment, in S105, the mouseenter event is monitored, and when the mouse moves into the element, the display logic is triggered and the show method inside the Element is called to display the element. <el-tooltip>Component, listens to the mouseleave event, when the mouse removes the element, triggers the hiding logic and calls the hide method inside the Element to hide it <el-tooltip>Component.
[0020] The beneficial effect of the present invention is: by registering in the global entry file main.js <el-tooltip>Components, ensuring that they do not need to be registered separately in each component, extension <el-tooltip>The function of the component and enhance flexibility, use the refName parameter to obtain the corresponding Vue.js instance project <el-tooltip>Component instances improve the flexibility and maintainability of the code by considering the type of parameters and the existence of global configuration items, so that the required functions can be correctly obtained in different situations. <el-tooltip>Component instances no longer accumulate infinitely through the reuse of temporary DOM elements, avoiding page freezes caused by too many DOM elements. By using the singleton mode to unify the entry, each instance can be configured separately, reducing a large amount of redundant configuration and display style unification, and adding additional functions more conveniently through unified encapsulation.
[0021] By introducing the Element UI component library in the Vue.js project and registering <el-tooltip>Components create unified entry nodes, combining custom logic, styles, and behaviors to optimize and expand <el-tooltip>Function of the component; obtained through the getTooltipVm function <el-tooltip>Component instance, and use event listeners to handle mouse events, to achieve precise control of mouse moving in and out of elements; at the same time, by creating temporary DOM elements and calculating text width, it ensures the display effect of long text and simplifies <el-tooltip>The display and hiding logic of components improves the maintainability, ease of use and user experience of components. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] Figure 1 is a flow chart of the method of the present invention; DETAILED DESCRIPTION
[0023] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of this application.
[0024] In the description of this application, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of the features. In the description of this application, "plurality" means two or more, unless otherwise clearly and specifically defined.
[0025] In the description of this application, the term "for example" is used to mean "used as an example, illustration or description". Any embodiment described as "for example" in this application is not necessarily to be construed as being preferred or advantageous over other embodiments. The following description is given to enable any technician in the field to implement and use the present invention. In the following description, details are listed for the purpose of explanation. It should be understood that a person of ordinary skill in the art can recognize that the present invention can be implemented without using these specific details. In other examples, well-known structures and processes will not be elaborated in detail to avoid obscuring the description of the present invention with unnecessary details. Therefore, the present invention is not intended to be limited to the embodiments shown, but is consistent with the widest scope consistent with the principles and features disclosed in this application.
[0026] This embodiment provides Figure 1 A single-case implementation method based on Element Tooltip text prompt is shown, which specifically includes the following steps:
[0027] S101. Introduce the Element UI component library in the Vue.js example project, using <el-tooltip>The component creates a unified entry node;
[0028] Furthermore, introduce the Element UI component library into the Vue.js example project and register it in the global entry file of main.js before creating the Vue.js example project. <el-tooltip>Components, using <el-tooltip>Components create a unified entry node through <el-tooltip>The component wraps the tooltip element and passes the tooltip element's content as a child component to <el-tooltip>This provides a unified entry point and simplifies <el-tooltip>The use and management of components improves the maintainability of the project.
[0029] Furthermore, the blm-tooltip.js file is imported and contains custom logic, styles, and behaviors for <el-tooltip>Customize, expand and enhance the functionality of components <el-tooltip>The function of the component is configured in the global entry file <el-tooltip>Component and set the ref attribute for reference, where the ref attribute specifies a reference name for the child component and DOM element. <el-tooltip>The component accesses the reference through the ref attribute. <el-tooltip>The component binds the unified configuration properties of tooltipOpt and passes the unified configuration properties of tooltipOpt to <el-tooltip>Component, the unified configuration attributes include <el-tooltip>The location and triggering method of the component, register the custom directive through the directives attribute in the global configuration object of the Vue.js project instance, use the v-blm-tooltip directive to activate the custom directive and use it in the el-input element, where the v-blm-tooltip directive passes a configuration object containing the blmOverWidthDisplay attribute with a value of true, which is used to control <el-tooltip>The display behavior of the component when the content is too long. <el-tooltip>The tooltipOpt configuration property solves the display problem when the content is too long and enhances <el-tooltip>Functionality of the component.
[0030] S102. Use the getTooltipVm function to receive parameters, and use the refName parameter to obtain the corresponding Vue.js instance project <el-tooltip>The instance of the component, the getTooltipVm function returns the obtained <el-tooltip>An instance of a component;
[0031] Further, the getTooltipVm function is used to receive parameters, including the vnode parameter for the virtual node, the refName parameter for the reference name, and the option object for initialization and acquisition. <el-tooltip>Component instance, use the vnode parameter to get the Vue.js instance project in the getTooltipVm function, and use the refName parameter to get the corresponding Vue.js instance project <el-tooltip>Component instance, additional options parameter <el-tooltip>The component instance performs content settings and location settings to check the global entry file configuration <el-tooltip>The existence of the global configuration item in the component. If the global configuration item exists, the refName parameter of the configuration item is used. If the global configuration item does not exist, the default name of blm-tooltip is used. The type of the refName parameter is determined to obtain the root instance. If refName is a string type, the root instance is obtained. <el-tooltip>The component instance is referenced by setting the ref attribute, and the corresponding refName parameter of the root instance is searched. <el-tooltip>Component instance. When refName is not a string type, the passed <el-tooltip>The instance of the component, the getTooltipVm function returns the obtained <el-tooltip>An instance of a component.
[0032] S103. Arrange onmouseover event listeners and onmouseout event listeners to capture events of mouse moving into and removing elements, use onEvent function to bind focus event processing to a specific DOM element and execute corresponding logic, use setReference function to receive the parameters of the element that currently triggers the mouse moving into event for mouseenter event; process mouse events through onmouseover and onmouseout event listeners. This improves the response speed and flexibility of components to user mouse events, making <el-tooltip>Components can better adapt to different usage scenarios.
[0033] Furthermore, the onEvent function is used to bind the mouse event processing to a specific DOM element, and the corresponding logic is executed when the mouse event occurs. The onmouseover event listener and the onmouseout event listener are arranged to capture the events of the mouse moving into and removing elements. When the mouse moves into an element, the setReference function is called to set the reference element and display it. <el-tooltip>Component, hide when the mouse moves out of the element <el-tooltip>Component, use the onEvent function to bind the focus event processing to a specific DOM element, and execute the corresponding logic when the focus event occurs. When the element gains focus, the focus event is triggered and the handleFocus function is called to handle the focus-related logic. When the element loses focus, the blur event is triggered and the popper.handleBlur function is called to handle the pop-up related logic. The handleFocus function is called to handle the focus-related logic. The correct management of the focus state is ensured by setting the correct focus style. When the element is clicked, the click event is triggered and the popper.removeFocusing function is called to remove the focus state. The text length is calculated by the caclTextWidth function, and the DOM element width is obtained by the calcWidth function. Accurate calculation and dynamic adjustment of text length are achieved to ensure <el-tooltip>The display effect of the component is not affected by the length of the text.
[0034] It should be noted that: by using the onEvent function to bind mouse events and focus events to specific DOM elements and executing the corresponding logic when the event occurs, this application achieves precise control of events such as mouse moving in and out, and element gaining and losing focus. The onmouseover event listener and onmouseout event listener arranged can capture the events of the mouse moving in and out of the element, and call the setReference function accordingly to set the reference element and show or hide <el-tooltip>Component, in addition, by processing the focus event, when the element gains focus, the focus event is triggered and the handleFocus function is called to handle the focus-related logic. When the element loses focus, the blur event is triggered and the popper.handleBlur function is called to handle the pop-up-related logic. By correctly setting the focus style, the correct management of the focus state is ensured. When the element is clicked, the click event is triggered and the popper.removeFocusing function is called to remove the focus state, thereby significantly improving <el-tooltip>The flexibility, responsiveness, and user experience of components in complex user interaction scenarios.
[0035] Furthermore, for the mouseenter event, the setReference function is used to receive the parameters of the element that currently triggers the mouse move event, and the current element is set to <el-tooltip>The reference object of the component, judging whether it should be displayed according to the configuration <el-tooltip>Component, when disabled in the configuration <el-tooltip>If the component is displayed, just select Return without processing, according to the configuration settings <el-tooltip>The component's content and position properties include <el-tooltip>The text content, style, and position of the component are dynamically adjusted according to the position of the mouse event <el-tooltip>The position of the component is used to ensure that the reference element is not obscured and the popper.show() method is called to display it. <el-tooltip>Components, of which popper is a popular tooltip library for management and control <el-tooltip>Display and hide components. By listening to mouseenter and mouseleave events, call the method inside the Element to handle <el-tooltip>Component display and hiding. Simplified <el-tooltip>The display and hiding logic of components improves the stability and reliability of components.
[0036] S104. Create a temporary DOM element and receive the text string parameter for which the text length needs to be calculated through the caclTextWidth function, and receive the DOM element parameter related to the width that needs to be calculated through the calcWidth function according to the temporary DOM element;
[0037] Furthermore, the caclTextWidth function receives as a parameter a text string whose text length needs to be calculated, creates a temporary DOM element, which is a span element, for accommodating the text content, sets the style of the temporary DOM element, including the font size and font style, for ensuring that the display effect of the text is the same as the text in the actual page, sets the incoming text string to the textContent attribute of the temporary DOM element for measuring the length of the text, adds the temporary DOM element to the document and obtains the text length through the clientWidth attribute of the temporary DOM element, and after obtaining the text length, removes the temporary DOM element to release memory space, and returns the text length as the return value of the function.
[0038] Furthermore, the calcWidth function receives the parameter of the DOM element whose width needs to be calculated, and calls the caclTextWidth function to calculate the width of the text content. When the passed-in DOM element is a container element, the width of the container is directly obtained through the clientWidth attribute of the element, and the width of the text content is assembled into an object and returned as the return value of the function.
[0039] S105. Call the method inside Element to listen to and process the events of Element UI components and complete <el-tooltip>Component display logic and hiding logic;
[0040] Furthermore, the mouseenter event is listened to. When the mouse moves into the element, the display logic is triggered and the show method inside the Element is called to display it. <el-tooltip>Component, listens to the mouseleave event, when the mouse removes the element, triggers the hiding logic and calls the hide method inside the Element to hide it <el-tooltip>Component, where the mouseleave event is different from the onmouseout event. The mouseleave event is only triggered when the mouse pointer leaves the boundary of the element.
[0041] By introducing the Element UI component library in the Vue.js project and registering <el-tooltip>Components create unified entry nodes, combining custom logic, styles, and behaviors to optimize and expand <el-tooltip>Function of the component; obtained through the getTooltipVm function <el-tooltip>Component instance, and use event listeners to handle mouse events, to achieve precise control of mouse moving in and out of elements; at the same time, by creating temporary DOM elements and calculating text width, it ensures the display effect of long text and simplifies <el-tooltip>The display and hiding logic of components improves the maintainability, ease of use and user experience of components.
[0042] It should be noted that in the above embodiments, the description of each embodiment has its own emphasis, and for parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0043] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0044] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded computer, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0045] These computer program instructions may also be stored in a computer readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0046] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0047] Although the preferred embodiments of the present invention have been described, those skilled in the art may make other changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the present invention.
[0048] Obviously, those skilled in the art can make various changes and modifications to the present invention without departing from the spirit and scope of the present invention. Thus, if these modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include these modifications and variations.
Claims
1. A singleton implementation method based on Element Tooltip text prompt, characterized in that: The specific steps include: S101. Introduce the Element UI component library in the Vue.js example project, using <el-tooltip> The component creates a unified entry node;< / el-tooltip> S102. Use the getTooltipVm function to receive parameters, and use the refName parameter to obtain the corresponding Vue.js instance project <el-tooltip>The instance of the component, the getTooltipVm function returns the obtained <el-tooltip> An instance of a component;< / el-tooltip> S103. Arrange onmouseover event listeners and onmouseout event listeners to capture events of mouse moving into and removing elements, use onEvent function to bind focus event processing to a specific DO M element and execute corresponding logic, and use setReference function to receive parameters for the current element that triggers the mouse moving into the event for the mouseenter event; S104. Create a temporary DOM element and receive the text string parameter for which the text length needs to be calculated through the caclTextWidth function, and receive the DOM element parameter related to the width that needs to be calculated through the calcWidth function according to the temporary DOM element; S105. Call the method inside Element to listen to and process the events of Element UI components and complete <el-tooltip> Component show logic and hide logic.< / el-tooltip> 2. A singleton implementation method based on Element Tooltip text prompt according to claim 1, characterized in that: In S101, before the Vue.js instance project is created, register in the global entry file of main.js <el-tooltip>Components, and create a unified entry node, through <el-tooltip>The component wraps the tooltip element, imports the blm-tooltip.js file and contains custom logic, style and behavior, and is configured in the global entry file <el-tooltip>Component and set the ref attribute to reference it. <el-tooltip>The component binds the unified configuration properties of tooltipOpt and passes the unified configuration properties of tooltipOpt to <el-tooltip> Component, register the custom directive through the directives property in the global configuration object of the Vue.js project instance, use the v-blm-tooltip directive to activate the custom directive and use it in the el-input element.< / el-tooltip> 3. A single-case implementation method based on Element Tooltip text prompt according to claim 1, characterized in that: In S102, the getTooltipVm function is used to receive parameters, the Vue.js instance project is obtained through the vnode parameter in the getTooltipVm function, and the refName parameter is used to obtain the corresponding Vue.js instance project. <el-tooltip>The instance of the component is referenced by setting the ref attribute and looking for the corresponding refName parameter in the root instance. <el-tooltip>The instance of the component, the getToo ltipVm function returns the obtained <el-tooltip> An instance of a component.< / el-tooltip> 4. A single-case implementation method based on Element Tooltip text prompt according to claim 1, characterized in that: In S103, the onEvent function is used to bind the mouse event processing to a specific DOM element, and the corresponding logic is executed when the mouse event occurs, and the onmouseover event listener and the onmouseout event listener are arranged to capture the events of the mouse moving into and removing elements. The corresponding logic is executed when the focus event occurs, the click event is triggered when the element is clicked, and the popper.removeFocusing function is called to remove the focus state.
5. A single-case implementation method based on Element Tooltip text prompt according to claim 4, characterized in that: The events of moving the mouse into and removing an element include: when the mouse moves into an element, calling the setReference function to set the reference element and displaying <el-tooltip>Component, hide when the mouse moves out of the element <el-tooltip> Component, use the onEvent function to bind focus event processing to a specific DOM element.< / el-tooltip> 6. A single-case implementation method based on Element Tooltip text prompt according to claim 4, characterized in that: The occurrence of the focus event includes: when the element obtains the focus, triggering the focus event and processing the focus-related logic by calling the handleFocus function; when the element loses the focus, triggering the blur event and calling the popper.handleBlur function to process the pop-up-related logic.
7. The singleton implementation method based on Element Tooltip text prompt according to claim 1, characterized in that: The caclTextWidth function receives the parameter of the text string whose text length needs to be calculated, creates a temporary DOM element, sets the passed text string as the textContent attribute of the temporary DOM element, adds the temporary DOM element to the document and obtains the text length through the stringWidth attribute of the temporary DOM element, returns the text length as the return value of the function, receives the parameter of the DOM element whose width needs to be calculated through the caclWidth function, calls the caclTextWidth function to calculate the width of the text content, composes the width of the text content into an object and returns it as the return value of the function.
8. The singleton implementation method based on Element Tooltip text prompt according to claim 1, characterized in that: In S105, the mouseenter event is monitored. When the mouse moves into the element, the display logic is triggered and the show method inside the Element is called to display the element. <el-tooltip>Component, listens to the mouseleave event, when the mouse removes the element, triggers the hiding logic and calls the hide method inside the Element to hide <el-tooltip> Component.< / el-tooltip>
