Vue framework naming conflict verification method, electronic equipment and storage medium
By converting the target code under the Vue framework into a structured mixin array, performing hierarchical traversal and multi-level validation, the naming conflict problem in Vue component development is solved, improving the accuracy of code validation and development efficiency.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-01-06
- Publication Date
- 2026-04-07
AI Technical Summary
In Vue 2 component development, as the project scales up, the mixin property mechanism causes naming conflicts, making it difficult to develop and debug code.
This paper provides a method for validating naming conflicts in the Vue framework. By converting the target code into a structured mixin array, the mixin objects are traversed according to their hierarchical relationship to perform file name validation, property information validation, and name duplication validation, thereby identifying file path errors, abnormal property definitions, and naming conflicts across mixins.
It improves the accuracy and comprehensiveness of code verification, optimizes the verification process, and enhances front-end development efficiency and system stability.
Smart Images

Figure CN121807724A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of front-end development technology, and more specifically, to a method for validating naming conflicts under the Vue framework, an electronic device, and a storage medium. Background Technology
[0002] Vue is a progressive JavaScript framework for building user interfaces. With its lightweight, easy-to-use, reactive data binding, and component-based architecture, it has become one of the mainstream frameworks in the front-end development field.
[0003] In Vue 2 component development, mixins are a widely used code reuse mechanism. However, as projects grow, mixins can lead to naming conflicts, making code development and debugging more difficult.
[0004] Therefore, a method to resolve naming conflicts is urgently needed. Summary of the Invention
[0005] The purpose of this application is to address the shortcomings of the prior art by providing a method, electronic device, and storage medium for verifying naming conflicts under the Vue framework, thereby improving the accuracy of name conflict verification under the Vue framework.
[0006] To achieve the above objectives, the technical solutions adopted in the embodiments of this application are as follows: In a first aspect, embodiments of this application provide a naming conflict verification method under the Vue framework, applied to a target plugin deployed in an electronic device, the method comprising: Obtain the target code to be verified for a Vue project, wherein the target code contains at least one mixin object and import information for each mixin object; The target code is converted into a structured mixin array, which represents each mixin object, the import information of each mixin object, and the hierarchical relationship between each mixin object in a structured form. According to the hierarchical relationship between each mixed object in the mixed array, each mixed object in the mixed array is traversed. For each traversed mixed object, the file name and attribute information of the mixed object are verified according to the import information of the mixed object, and the verification result of the mixed object is obtained. Based on the verification results of each mixed-in object in the mixed-in array, intermediate verification mixed-in objects are determined, and named duplicate verification is performed on each intermediate verification mixed-in object to obtain the target verification result.
[0007] Optionally, the step of performing filename verification and attribute information verification on the mixed-in object based on the import information of the mixed-in object to obtain the verification result of the mixed-in object includes: The filename of the mixed-in object is verified based on the import information of the mixed-in object to determine whether the mixed-in information of the mixed-in object meets the preset conditions; If so, the attribute information of the mixed-in object is verified to obtain the attribute verification result; If the attribute verification result is normal, then the verification result is determined to be normal.
[0008] Optionally, the step of verifying the filename of the mixed-in object based on its import information to determine whether the import information of the mixed-in object meets preset conditions includes: Obtain the file path and name information from the import information of the mixed-in object; Based on the name information and the file path, determine whether the import information of the mixed-in object meets the preset conditions.
[0009] Optionally, determining whether the import information of the mixed-in object meets the preset conditions based on the name information and the file path includes: The imported name and the original name in the name information are compared to determine whether the imported name and the original name are consistent. If they match, the namespace of the mixed-in object is extracted from the name information, and it is determined whether the file path contains the namespace. If the file path contains the namespace, then the import information of the mixed-in object is determined to meet the preset conditions.
[0010] Optionally, the step of validating the attribute information of the mixed-in object to obtain the attribute validation result includes: Determine whether the attribute information contains a preset attribute; If so, determine the attribute value of the preset attribute, and determine whether the attribute name suffix of other attributes besides the preset attribute is the same as the attribute value; If they are the same, the attribute verification result is normal; if they are different, the attribute verification result is abnormal.
[0011] Optionally, the step of determining intermediate verification mixed-in objects based on the verification results of each mixed-in object in the mixed-in array, and performing named duplicate verification on each intermediate verification mixed-in object to obtain the target verification result includes: If the verification result of the mixed object is normal, then the mixed object is used as the intermediate verification mixed object, and repeatability verification and suffix verification are performed on each of the intermediate verification mixed objects. The target verification result is determined based on the repeatability verification result and the suffix verification result.
[0012] Optionally, the step of performing duplicate checks and suffix checks on each of the intermediate verification mixed-in objects includes: Perform a duplicate check on the namespace of each of the intermediate verification mixed-in objects, and determine the duplicate check result; The suffix verification result is determined based on the namespace of each intermediate verification mixed-in object and the preset namespace.
[0013] Optionally, it also includes: If the function called by the mixed-in object is a preset function, and the attribute information of the mixed-in object contains a preset attribute, and the name information of the mixed-in object contains a namespace, then the mixed-in object is determined to be a global call object.
[0014] Secondly, this application also provides a naming conflict verification device under the Vue framework, the device comprising: The acquisition module is used to acquire the target code to be verified for a Vue project. The target code contains at least one mixin object and the import information of each mixin object. The conversion module is used to convert the target code into a structured mixin array, wherein the mixin array represents each mixin object, the import information of each mixin object, and the hierarchical relationship between each mixin object in a structured form; The determination module is used to traverse each mixin object in the mixin array according to the hierarchical relationship between each mixin object in the mixin array, and for each traversed mixin object, to perform file name verification and attribute information verification on the mixin object according to the import information of the mixin object, and obtain the verification result of the mixin object. The determining module is further configured to determine intermediate verification mixed objects based on the verification results of each mixed object in the mixed array, perform named duplicate verification on each intermediate verification mixed object, and obtain the target verification result.
[0015] Optionally, the determining module is specifically used for: The filename of the mixed-in object is verified based on the import information of the mixed-in object to determine whether the mixed-in information of the mixed-in object meets the preset conditions; If so, the attribute information of the mixed-in object is verified to obtain the attribute verification result; If the attribute verification result is normal, then the verification result is determined to be normal.
[0016] Optionally, the determining module is specifically used for: Obtain the file path and name information from the import information of the mixed-in object; Based on the name information and the file path, determine whether the import information of the mixed-in object meets the preset conditions.
[0017] Optionally, the determining module is specifically used for: The imported name and the original name in the name information are compared to determine whether the imported name and the original name are consistent. If they match, the namespace of the mixed-in object is extracted from the name information, and it is determined whether the file path contains the namespace. If the file path contains the namespace, then the import information of the mixed-in object is determined to meet the preset conditions.
[0018] Optionally, the determining module is specifically used for: Determine whether the attribute information contains a preset attribute; If so, determine the attribute value of the preset attribute, and determine whether the attribute name suffix of other attributes besides the preset attribute is the same as the attribute value; If they are the same, the attribute verification result is normal; if they are different, the attribute verification result is abnormal.
[0019] Optionally, the determining module is specifically used for: If the verification result of the mixed object is normal, then the mixed object is used as the intermediate verification mixed object, and repeatability verification and suffix verification are performed on each of the intermediate verification mixed objects. The target verification result is determined based on the repeatability verification result and the suffix verification result.
[0020] Optionally, the determining module is specifically used for: Perform a duplicate check on the namespace of each of the intermediate verification mixed-in objects, and determine the duplicate check result; The suffix verification result is determined based on the namespace of each intermediate verification mixed-in object and the preset namespace.
[0021] Optionally, the determining module is further specifically used for: If the function called by the mixed-in object is a preset function, and the attribute information of the mixed-in object contains a preset attribute, and the name information of the mixed-in object contains a namespace, then the mixed-in object is determined to be a global call object.
[0022] Thirdly, embodiments of this application also provide an electronic device, including: a processor, a memory, and a bus. The memory stores program instructions executable by the processor. When the application runs, the processor communicates with the memory via the bus, and the processor executes the program instructions to perform the steps of the naming conflict verification method under the Vue framework described in the first aspect.
[0023] Fourthly, embodiments of this application also provide a computer-readable storage medium storing a computer program, which is read and executes the steps of the naming conflict verification method under the Vue framework described in the first aspect.
[0024] The beneficial effects of this application are: This application provides a naming conflict verification method, electronic device, and storage medium under the Vue framework. It converts the target code into a structured mixin array. According to the hierarchical relationship between the mixin objects in the mixin array, each mixin object is traversed. For each traversed mixin object, filename and attribute information verification is performed based on its import information to obtain the verification result. Intermediate verification mixin objects are determined based on the verification results of each mixin object in the mixin array. Name duplication verification is performed on each intermediate verification mixin object to obtain the target verification result. By converting unstructured code into a structured mixin array, it supports precise modeling and traversal control of complex hierarchical relationships between mixin objects. A multi-level verification mechanism, including filename verification, attribute verification, and duplication verification, filters out invalid or non-compliant mixin objects layer by layer. It can automatically identify problems such as incorrect file paths, abnormal attribute definitions, and cross-mixin naming conflicts before code execution, improving the accuracy and comprehensiveness of code verification. Furthermore, by performing basic validation first and then name duplication analysis, the validation process is optimized and resource utilization is improved, which helps to improve front-end development efficiency and system stability. Attached Figure Description
[0025] To more clearly illustrate the technical solutions of the embodiments of this application, the accompanying drawings used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of this application and should not be regarded as a limitation of the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0026] Figure 1 A flowchart illustrating a naming conflict verification method under the Vue framework provided in this application embodiment; Figure 2A flowchart illustrating the second naming conflict verification method under the Vue framework provided in this application embodiment; Figure 3 A flowchart illustrating the third naming conflict verification method under the Vue framework provided in this application embodiment; Figure 4 A flowchart illustrating the fourth naming conflict verification method under the Vue framework provided in this application embodiment; Figure 5 A flowchart illustrating the fifth naming conflict verification method under the Vue framework provided in this application embodiment; Figure 6 A schematic diagram of an apparatus for a naming conflict verification method under the Vue framework provided in an embodiment of this application; Figure 7 This is a structural block diagram of an electronic device provided in an embodiment of this application. Detailed Implementation
[0027] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. It should be understood that the accompanying drawings in this application are for illustrative and descriptive purposes only and are not intended to limit the scope of protection of this application. Furthermore, it should be understood that the schematic drawings are not drawn to scale. The flowcharts used in this application illustrate operations implemented according to some embodiments of this application. It should be understood that the operations in the flowcharts may not be implemented in sequence, and steps without logical contextual relationships may be reversed or implemented simultaneously. In addition, those skilled in the art, guided by the content of this application, may add one or more other operations to the flowcharts, or remove one or more operations from the flowcharts.
[0028] Furthermore, the described embodiments are merely some, not all, of the embodiments of this application. The components of the embodiments of this application described and illustrated herein can typically be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of this application provided in the accompanying drawings is not intended to limit the scope of the claimed application, but merely to illustrate selected embodiments of the application. All other embodiments obtained by those skilled in the art based on the embodiments of this application without inventive effort are within the scope of protection of this application.
[0029] It should be noted that the term "comprising" will be used in the embodiments of this application to indicate the presence of the features declared thereafter, but does not exclude the addition of other features.
[0030] Optionally, the naming conflict verification method under the Vue framework provided in this application embodiment is applied to target plugins in electronic devices. These electronic devices can be terminal devices with computing power and display functions, such as mobile phones, tablets, laptops, PDAs, and desktop computers, or they can be servers. Specifically, it can be applied to applications in terminal devices, such as mobile phone applications (APPs) and computer application systems.
[0031] This target plugin is a custom plugin for Eslint, developed based on Eslint. Its main function is to ensure that the naming and usage of mixins conform to a unified namespace specification.
[0032] During the initialization phase of this target plugin, Abstract Syntax Tree (AST) generation can be performed; specifically, using Vue.js... eslint The `parser`, acting as the ESLint parser, interprets the contents of Vue and JavaScript files into an Abstract Syntax Tree (AST). The AST content can be obtained through the `context` parameter of the `create` plugin. A Map object `imports` is created to store information about all import statements related to the mixins array, including the original import names and file paths. This map plays a crucial role in subsequent reference consistency checks. A Set object `mixinNamespaces` is created to record namespaces appearing in the same mixins array, preventing duplicates. The automatic deduplication feature of the Set data structure makes duplicate checks simple and efficient. A variable `currentMixin` is initialized to track the currently processed mixin object definition. When a mixin object definition is encountered, this variable is initialized and its relevant state is recorded for subsequent property validation.
[0033] The following section will explain in detail the specific implementation process of the naming conflict verification under the Vue framework provided in the embodiments of this application.
[0034] Figure 1 This is a flowchart illustrating a naming conflict verification method within the Vue framework, provided as an embodiment of this application. The execution subject of this method is, as described above, the target plugin in the electronic device. Figure 1 As shown, the method includes: S101. Obtain the target code to be verified for the Vue project.
[0035] The target code for the Vue project may contain at least one mixin object and import information for each mixin object. The import information is called import information, and the mixin object is called mixin.
[0036] Specifically, the target plugin retrieves the target code to be verified from the current project's source code directory or the editor's memory. This target code contains JavaScript or TypeScript files defining Vue components, including at least one mixin object and its import information. A mixin object refers to a reusable object module imported into a Vue component via the `mixins` option, typically used to achieve logic reuse between components. Import information includes, but is not limited to, the mixin object's file path, name, and filename.
[0037] S102. Convert the target code into a structured mixin array.
[0038] The mixin array represents each mixin object, its import information, and the hierarchical relationships between them in a structured form.
[0039] Optionally, after obtaining the target code, the target plugin performs AST parsing on the target code, for example, using ESTree or Babel Parser to construct an abstract syntax tree and extract all mixin objects from the target code. Based on the parsing results, the multiple mixin objects in the target code and their import information are integrated into a structured mixin array. This mixin array not only contains the name of each mixin object but also explicitly expresses the hierarchical relationships between them, such as parent-child relationships, parallel import relationships, etc. Each item in the structured mixin array is a structured object. This structured array enables standardized modeling of unstructured code, facilitating subsequent sequential traversal and multi-dimensional validation.
[0040] S103. According to the hierarchical relationship between each mixed-in object in the mixed-in array, traverse each mixed-in object in the mixed-in array. For each mixed-in object that is traversed, perform file name verification and attribute information verification on the mixed-in object based on the import information of the mixed-in object, and obtain the verification result of the mixed-in object.
[0041] Specifically, after obtaining the structured mixin array, each mixin object is traversed according to its hierarchical relationship, such as parent-child, depth-first, or breadth-first order. For each traversed mixin object, two levels of validation are performed based on its import information: filename validation and attribute information validation. The final validation result of the mixin object is then generated. This result can be either normal or abnormal.
[0042] S104. Determine intermediate verification mixed objects based on the verification results of each mixed object in the mixed array, perform named duplicate verification on each intermediate verification mixed object, and obtain the target verification result.
[0043] Optionally, after traversing and performing preliminary validation on all mixed-in objects, intermediate validation mixed-in objects can be selected based on the validation results of each mixed-in object. Name duplication validation can then be performed on each intermediate validation mixed-in object, ultimately generating the target validation result for each mixed-in object.
[0044] In this embodiment, the target code is converted into a structured mixin array. Based on the hierarchical relationship between the mixin objects in the mixin array, each mixin object is traversed. For each traversed mixin object, filename and attribute information validation is performed based on its import information to obtain the validation result. Intermediate validation mixin objects are determined based on the validation results of each mixin object in the mixin array. Name duplication validation is performed on each intermediate validation mixin object to obtain the target validation result. By converting unstructured code into a structured mixin array, accurate modeling and traversal control of complex hierarchical relationships between mixin objects are supported. A multi-level validation mechanism, including filename validation, attribute validation, and duplication validation, filters out invalid or non-compliant mixin objects at each level. This automatically identifies issues such as incorrect file paths, abnormal attribute definitions, and cross-mixin naming conflicts before code execution, improving the accuracy and comprehensiveness of code validation. Furthermore, by performing basic validation first and then name duplication analysis, the validation process is optimized and resource utilization is improved, contributing to increased front-end development efficiency and system stability.
[0045] Figure 2 A flowchart illustrating the second naming conflict verification method under the Vue framework provided in this application embodiment is shown below. Figure 2 As shown, in step S103 above, the filename and attribute information of the mixed-in object are verified based on the import information of the mixed-in object to obtain the verification result of the mixed-in object, which may include: S201. Verify the filename of the mixed-in object based on its import information to determine whether the import information of the mixed-in object meets the preset conditions.
[0046] Specifically, if the mixed-in object meets the preset conditions, then step S202 is executed; if the mixed-in object does not meet the preset conditions, then step S206 is executed.
[0047] Specifically, the filename of the mixed-in object can be verified based on information such as the file path in the import information of the mixed-in object, thereby determining whether the import information of the mixed-in object meets the preset conditions.
[0048] S202. Verify the attribute information of the mixed-in object and obtain the attribute verification result.
[0049] Optionally, if the filename of the mixed-in object meets a preset condition, the attribute information of the mixed-in object is further validated to obtain the attribute validation result of the mixed-in object. The attribute validation result may include normal or abnormal.
[0050] S203. Determine whether the attribute validation result is normal.
[0051] Specifically, if the attribute verification result is normal, then proceed to step S204 below; if the attribute verification result is abnormal, then proceed to step S205 below.
[0052] S204, The verification result of the mixed-in object is normal.
[0053] Optionally, if the filename of the mixed-in object meets the preset conditions and the attribute verification result of the mixed-in object is also normal, it means that the verification result of the mixed-in object is normal.
[0054] S205, Output attribute verification error message.
[0055] The error message for this attribute validation can be either "The mixed-in object does not include the preset attribute" or "The attribute value whose suffix is not the preset attribute".
[0056] S206. Output filename verification error message.
[0057] The error message for filename verification can be either "The file path in the import information does not contain a namespace" or "The import information was renamed using preset characters".
[0058] In this embodiment, filename verification based on import information is introduced as a precondition. Only after confirming the validity of the external resources upon which the mixed-in object depends is further verified of its internal attribute information. This phased, condition-driven verification method effectively avoids redundant deep semantic analysis on invalid or missing files, significantly reducing computational resource consumption and improving verification efficiency and accuracy. Simultaneously, by dividing the verification process into multiple interdependent layers, error localization becomes clearer, enhancing the development and debugging experience. Finally, the verification result is considered "normal" only when the file exists and its attributes are compliant, ensuring high reliability of the output and facilitating high-quality mixed-in code management in front-end engineering.
[0059] Figure 3A flowchart illustrating the third naming conflict verification method under the Vue framework provided in this application embodiment is shown below. Figure 3 As shown, in step S201 above, the filename verification of the mixed-in object based on its import information to determine whether the import information of the mixed-in object meets preset conditions may include: S301. Obtain the file path and name information from the import information of the mixed-in object.
[0060] The name information can include the import name and the original name of the mixin object. The import name is like "specifier.imported.name", the original name is like "specifier.local.name", and the name of a specific mixin object is like "useMixinsAdmin". The file path refers to the file path where the mixin object is stored.
[0061] S302. Based on the name information and file path, determine whether the import information of the mixed-in object meets the preset conditions.
[0062] Specifically, compliance checks can be performed on the renaming of the mixed-in object based on the name information. The file path of the mixed-in object can also be checked based on the name information and the file path to determine the existence of the file and the legality of the file path. Then, based on the obtained renaming check and file path check, it can be determined whether the import information of the mixed-in object meets the preset conditions, that is, whether the import information of the mixed-in object meets the preset conditions.
[0063] In this embodiment, a pre-verification mechanism for mixed-in object dependencies is constructed. Only when the referenced target file actually exists, the path is valid, and the naming is standardized, is it considered to meet preset conditions, thus initiating the subsequent verification process. This mechanism significantly reduces invalid analysis operations caused by incorrect paths, missing files, or inconsistent naming, reduces system resource consumption, and improves the response speed and diagnostic reliability of code quality detection.
[0064] Figure 4 A flowchart illustrating the fourth naming conflict verification method under the Vue framework provided in this application embodiment is shown below. Figure 4 As shown, in step S302 above, determining whether the import information of the mixed-in object meets the preset conditions based on the name information and file path may include: S401. Compare the imported name and the original name in the name information to determine whether the imported name and the original name are consistent.
[0065] Specifically, if the imported name is the same as the original name, it means that the renaming of the mixed-in object conforms to the naming convention, and the following step S402 is executed; if the imported name is different from the original name, it means that the renaming of the mixed-in object does not conform to the naming convention, and the following step S405 is executed.
[0066] For example, if the import name in the import information is inconsistent with the original name (e.g., the import name contains the keyword "as" but the original name does not), it indicates that the import name in the import information does not conform to the naming conventions. If neither the import name nor the original name contains the keyword "as," and the import name is consistent with the original name, it indicates that the import name conforms to the naming conventions. This ensures that the import name of the mixed-in object remains consistent with the source file name.
[0067] S402. Extract the namespace of the mixed-in object from the name information and determine whether the file path contains the namespace.
[0068] Optionally, once it is determined that the name information of the mixed-in object conforms to the naming convention, the namespace can be extracted from the name information, and it can be determined whether the file path of the mixed-in object contains the namespace.
[0069] Specifically, if the file path contains the namespace extracted from the name information of the mixed-in object, then step S403 is executed; if the file path does not contain the namespace extracted from the name information of the mixed-in object, then step S404 is executed.
[0070] For example, if the namespace "Admin" is extracted from the name information "useMixinsAdmin" of the mixin object, and it is determined whether the file path of the mixin object contains "Admin".
[0071] S403. Determine that the import information of the mixed-in object meets the preset conditions.
[0072] S404, The output file path does not contain a namespace.
[0073] S405. Output a message indicating that the renaming does not conform to the naming convention.
[0074] In this embodiment, by comparing the imported name of the mixed-in object with its original name and further extracting its namespace to verify the structural compliance of the file path, dual protection is achieved for the consistency of code organization logic and physical layout. This mechanism can effectively identify the risk of module coupling caused by factors such as inconsistent naming and misplaced paths, improving the architectural clarity and maintainability of the front-end project. Furthermore, the import information is only considered valid when all the above conditions are met, significantly reducing redundant processing of abnormal structure code, optimizing the allocation of verification resources, and improving system operating efficiency and diagnostic accuracy.
[0075] Optionally, the verification of the attribute information of the mixed-in object in S202 above, to obtain the attribute verification result, may include: Specifically, determine whether the attribute information contains a preset attribute. If the attribute value of the preset attribute is determined, determine whether the attribute name suffix of other attributes besides the preset attribute is the same as the attribute value.
[0076] If the suffix of the attribute name of other attributes is the same as the attribute value, it means that the attribute validation result is normal; if the suffix of the attribute name of other attributes is different from the attribute value, it means that the attribute validation result is abnormal.
[0077] The preset attribute could be, for example, the "mixinSpace" attribute. If the attribute information does not contain the preset attribute, the user will be prompted that "the attribute information does not contain the preset attribute". The user will then manually add the preset attribute and its value, such as "Admin" for the "mixinSpace" attribute.
[0078] For example, for other attributes besides the "mixinSpace" attribute, such as the data attribute, methods attribute, and computed attribute, if the attribute name suffix of other attributes all ends with "Admin", then the naming convention of other attributes is followed, and the attribute validation result is normal; if there are other attributes whose attribute name suffix does not end with "Admin", then the message "mixin attribute lacks the correct namespace suffix" can be output to the user.
[0079] Optionally, in step S104 above, determining intermediate verification mixin objects based on the verification results of each mixin object in the mixin array, performing named duplicate verification on each intermediate verification mixin object, and obtaining the target verification result may include: Optionally, if the verification result of the mixed object is normal, the mixed object is used as an intermediate verification mixed object, and repeatability and suffix verification are performed on the intermediate verification mixed object. The target verification result is determined based on the repeatability verification result and the suffix verification result.
[0080] Specifically, if both the duplicate check result and the suffix check result are normal, then the target check result is normal, meaning the check result of the array to be checked is normal. If the duplicate check result is abnormal and / or the suffix check result is abnormal, then the target check result is abnormal, meaning the check result of the array to be checked is abnormal.
[0081] Specifically, a Set type data mixinNamespaces can be created to perform validation of each intermediate validation mixin object.
[0082] Figure 5 A flowchart illustrating the fifth naming conflict verification method under the Vue framework provided in this application embodiment is shown below. Figure 5 As shown, the above-mentioned duplicate and suffix checks on each intermediate check mix-in object can include: S501. Perform duplicate checks on the namespaces of each intermediate check mixed-in object and determine the duplicate check results.
[0083] Specifically, the mixinNamespaces collection can be used to determine whether there are duplicate namespaces in the intermediate mixed-in objects. If a duplicate exists, the duplicate check result of the mixed-in array to be checked is abnormal, and an error message such as "Duplicate namespace in the array to be checked" is output; if no duplicate exists, the duplicate check result of the mixed-in array to be checked is normal.
[0084] S502. Determine the suffix verification result based on the namespace of each intermediate verification mixed-in object and the preset namespace.
[0085] Specifically, you can check if the namespaces of each intermediate validation mixin object end with the correct namespace suffix. For example, "useMixinsAdmin" should end with "Admin". If not, output an error message.
[0086] Optionally, the method may further include: if the calling function of the mixin object is a preset calling function, and the property information of the mixin object contains a preset property, and the name information of the mixin object contains a namespace, then the mixin object is determined to be a global calling object. The preset calling function is, for example, "mixin()" or "Vue.mixin()". The preset property is, for example, "mixinSpace".
[0087] Figure 6 A schematic diagram of an apparatus for a naming conflict verification method under the Vue framework provided in this application embodiment is shown below. Figure 6 As shown, the device includes: The acquisition module 601 is used to acquire the target code to be verified, wherein the target code contains at least one mixin object and import information of each mixin object; The conversion module 602 is used to convert the target code into a structured mixin array, wherein the mixin array represents each mixin object, the import information of each mixin object, and the hierarchical relationship between each mixin object in a structured form; The determination module 603 is used to traverse each mixed object in the mixed array according to the hierarchical relationship between each mixed object in the mixed array, and for each mixed object that is traversed, to perform file name verification and attribute information verification on the mixed object according to the import information of the mixed object, and to obtain the verification result of the mixed object. The determining module is further configured to determine intermediate verification mixed objects based on the verification results of each mixed object in the mixed array, perform named duplicate verification on each intermediate verification mixed object, and obtain the target verification result.
[0088] Optionally, the determining module 603 is specifically used for: The filename of the mixed-in object is verified based on the import information of the mixed-in object to determine whether the mixed-in information of the mixed-in object meets the preset conditions; If so, the attribute information of the mixed-in object is verified to obtain the attribute verification result; If the attribute verification result is normal, then the verification result is determined to be normal.
[0089] Optionally, the determining module 603 is specifically used for: Obtain the file path and name information from the import information of the mixed-in object; Based on the name information and the file path, determine whether the import information of the mixed-in object meets the preset conditions.
[0090] Optionally, the determining module 603 is specifically used for: The imported name and the original name in the name information are compared to determine whether the imported name and the original name are consistent. If they match, the namespace of the mixed-in object is extracted from the name information, and it is determined whether the file path contains the namespace. If the file path contains the namespace, then the import information of the mixed-in object is determined to meet the preset conditions.
[0091] Optionally, the determining module 603 is specifically used for: Determine whether the attribute information contains a preset attribute; If so, determine the attribute value of the preset attribute, and determine whether the attribute name suffix of other attributes besides the preset attribute is the same as the attribute value; If they are the same, the attribute verification result is normal; if they are different, the attribute verification result is abnormal.
[0092] Optionally, the determining module 603 is specifically used for: If the verification result of the mixed object is normal, then the mixed object is used as the intermediate verification mixed object, and repeatability verification and suffix verification are performed on each of the intermediate verification mixed objects. The target verification result is determined based on the repeatability verification result and the suffix verification result.
[0093] Optionally, the determining module 603 is specifically used for: Perform a duplicate check on the namespace of each of the intermediate verification mixed-in objects, and determine the duplicate check result; The suffix verification result is determined based on the namespace of each intermediate verification mixed-in object and the preset namespace.
[0094] Optionally, the determining module 603 is further specifically used for: If the function called by the mixed-in object is a preset function, and the attribute information of the mixed-in object contains a preset attribute, and the name information of the mixed-in object contains a namespace, then the mixed-in object is determined to be a global call object. Figure 7 This is a structural block diagram of an electronic device 700 provided in an embodiment of this application. (See diagram below.) Figure 7 As shown, the electronic device may include: a processor 701 and a memory 702.
[0095] Optionally, a bus 703 may also be included, wherein the memory 702 is used to store machine-readable instructions executable by the processor 701. When the electronic device 700 is running, the processor 701 communicates with the memory 702 via the bus 703, and the processor 701 executes the machine-readable instructions to perform the method steps in the above method embodiments.
[0096] This application also provides a computer-readable storage medium storing a computer program, which, when run by a processor, executes the method steps described in the above-described embodiment of the naming conflict verification method under the Vue framework.
[0097] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems and devices described above can be referred to the corresponding processes in the method embodiments, and will not be repeated here. In the several embodiments provided in this application, it should be understood that the disclosed systems and methods can be implemented in other ways. The device embodiments described above are merely illustrative. For example, the division of modules is only a logical functional division, and in actual implementation, there may be other division methods. Furthermore, multiple modules or components may be combined or integrated into another system, or some features may be ignored or not executed. Another point is that the displayed or discussed mutual coupling or direct coupling or communication connection may be through some communication interfaces; the indirect coupling or communication connection of devices or modules may be electrical, mechanical, or other forms.
[0098] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. If the functions are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes: USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, optical disks, and other media capable of storing program code.
[0099] The above are merely specific embodiments of this application, but the scope of protection of this application is not limited thereto. Any changes or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application.
Claims
1. A method for validating naming conflicts in the Vue framework, characterized in that, The method, applied to a target plug-in deployed in an electronic device, includes: Obtain the target code to be verified for a Vue project, wherein the target code contains at least one mixin object and import information for each mixin object; The target code is converted into a structured mixin array, which represents each mixin object, the import information of each mixin object, and the hierarchical relationship between each mixin object in a structured form. According to the hierarchical relationship between each mixed object in the mixed array, each mixed object in the mixed array is traversed. For each traversed mixed object, the file name and attribute information of the mixed object are verified according to the import information of the mixed object, and the verification result of the mixed object is obtained. Based on the verification results of each mixed-in object in the mixed-in array, intermediate verification mixed-in objects are determined, and named duplicate verification is performed on each intermediate verification mixed-in object to obtain the target verification result.
2. The naming conflict verification method under the Vue framework according to claim 1, characterized in that, The step of verifying the filename and attribute information of the mixed-in object based on its import information to obtain the verification result of the mixed-in object includes: The filename of the mixed-in object is verified based on the import information of the mixed-in object to determine whether the mixed-in information of the mixed-in object meets the preset conditions; If so, the attribute information of the mixed-in object is verified to obtain the attribute verification result; If the attribute verification result is normal, then the verification result is determined to be normal.
3. The naming conflict verification method under the Vue framework according to claim 2, characterized in that, The step of verifying the filename of the mixed-in object based on its import information to determine whether the import information of the mixed-in object meets preset conditions includes: Obtain the file path and name information from the import information of the mixed-in object; Based on the name information and the file path, determine whether the import information of the mixed-in object meets the preset conditions.
4. The naming conflict verification method under the Vue framework according to claim 3, characterized in that, The step of determining whether the import information of the mixed-in object meets the preset conditions based on the name information and the file path includes: The imported name and the original name in the name information are compared to determine whether the imported name and the original name are consistent. If they match, the namespace of the mixed-in object is extracted from the name information, and it is determined whether the file path contains the namespace. If the file path contains the namespace, then the import information of the mixed-in object is determined to meet the preset conditions.
5. The naming conflict verification method under the Vue framework according to claim 2, characterized in that, The step of validating the attribute information of the mixed-in object to obtain the attribute validation result includes: Determine whether the attribute information contains a preset attribute; If so, determine the attribute value of the preset attribute, and determine whether the attribute name suffix of other attributes besides the preset attribute is the same as the attribute value; If they are the same, the attribute verification result is normal; if they are different, the attribute verification result is abnormal.
6. The naming conflict verification method under the Vue framework according to claim 1, characterized in that, The step of determining intermediate verification mixin objects based on the verification results of each mixin object in the mixin array, performing named duplicate verification on each intermediate verification mixin object, and obtaining the target verification result includes: If the verification result of the mixed object is normal, then the mixed object is used as the intermediate verification mixed object, and repeatability verification and suffix verification are performed on each of the intermediate verification mixed objects. The target verification result is determined based on the repeatability verification result and the suffix verification result.
7. The naming conflict verification method under the Vue framework according to claim 6, characterized in that, The process of performing duplicate checks and suffix checks on each of the intermediate verification mixed-in objects includes: Perform a duplicate check on the namespace of each of the intermediate verification mixed-in objects, and determine the duplicate check result; The suffix verification result is determined based on the namespace of each intermediate verification mixed-in object and the preset namespace.
8. The naming conflict verification method under the Vue framework according to claim 1, characterized in that, Also includes: If the function called by the mixed-in object is a preset function, and the attribute information of the mixed-in object contains a preset attribute, and the name information of the mixed-in object contains a namespace, then the mixed-in object is determined to be a global call object.
9. An electronic device, characterized in that, The device includes a memory and a processor, wherein the memory stores a computer program executable by the processor, and the processor executes the computer program to implement the steps of the naming conflict verification method under the Vue framework as described in any one of claims 1-8.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, performs the steps of the naming conflict verification method under the Vue framework as described in any one of claims 1-8.