Foreword
this project API>= 13
regarding the componentized operation of Hongmeng Project, two methods have been shared, namely IDE plug-in method and node script method. Today, we bring the third method, Hvigor plug-in method. Different from the first two methods, it is simpler to use and can run components without manual switching.
hvigor plugin dependency
at present, the plug-in has been released to the npm platform with the version number of 1.1.8. You can rely on the plug-in as follows. In the hvigor-config.json5 under hvigor Directory, find dependencies and add "quick-assembly": "1.1.8" to it, as shown in the following figure:
after relying on the plug-in, it will automatically download the resource package. We can use the plug-in in the module or hvigorfile.ts under the root project in the following way:
after the above two steps are completed, our plug-in dependency is completed.
hvigor plugin using
the use of the hvigor plug-in is completely different from the previous two methods. It will automatically identify the module you are currently running without switching again separately. For example, if you want to run a module, you can directly run it after selecting it at the top.
Of course, synchronization and refreshing of projects must be performed. This is the same as the first two methods. When you switch to direct operation, an error will be reported. This error does not matter.
Find Sync and Refresh Project under File and click.
Because all modules share the same package name, when there are applications with the same package name on the device, the following error will be reported. This is the same as the first two. We can click blue directly.
In this way, we have a single module running independently.
Related Summary
at present, when running for the first time, a harmonyComponent.json5 file will be generated under the root project. The main purpose of this file is to control whether the plug-in is executed. The default is true. The plug-in will be executed every time it runs, and false will not execute the plug-in content.
Of course, if it is true, the script will not be executed every time, but only once after switching. If the next module is the same as the last module, it will only run once, and the script will only be executed when the next module is different from the last one.
Just like the previous two methods, if you do not configure the default Ability, you will only install it at runtime and will not start the default page. You need to manually configure the default Ability for the module separately, and this action can only be configured once.
This article label: Hongmeng Development Tools/DevEco Studio
Top comments (0)