头图

The mini code has been "sub-module mixed development" capability.

On the basis of visual editing applications, users can enjoy a more complete one-stop development experience through code development and application deployment.

The following will introduce in detail the usage scenarios and usage methods of sub-module hybrid development.

application scenario

Application Scenario 1: Multi-team development

When developing a large-scale project, it is often not something that a main development team can develop alone. The collaboration scenario of a large-scale project determines the mode that requires multi-team collaborative development. However, when multiple teams develop a project collaboratively, they will encounter various problems. If they are not handled well, it will cause problems such as low development efficiency and delay in progress, which is a major risk point of the project.

Application Scenario 2: Low-code development combined with traditional coding

Some of the widget users do not develop from scratch, they will encounter the problem of migration of existing applications. Sometimes due to time, it is difficult to low-code migration of all the content of the application.

solution: sub-module mixed development

In view of the above pain points, we can use sub-module mixed development to solve.
Tencent Cloud Microcode provides a way to develop and deploy applications through code based on visual editing applications. It has the following advantages:

  • An application can be divided into a main module and multiple sub-modules , which can be developed in different modules;
  • The modules are decoupled and relatively independent;
  • Each module supports [low code development] and [upload code package] two development modes;
  • After the development is completed, the micro-building platform will complete the merge, package and release, the whole process is convenient and trouble-free.

basic concepts:

  • Application main module: Each application must contain a unique application main module. Compared with the sub-module, the main module has an application-level configuration.
  • Application sub-modules: Each application can contain N sub-modules, and how to split is based on the developer's configuration.
  • Low-code development mode: Visual development through mini-build low-code.
  • Upload code package mode: Allow users to upload code packages in traditional development mode.

Note: Currently, only mixed development of small programs is supported.

use

To use sub-module mixed development, you need to clarify the main and sub-relationships. The low-code mode of each module is considered to be a low-code editing application, and the code package is considered to be a native applet application.

  • The code package as the main module: It is necessary to ensure that the content is a complete small program project code, and the project structure meets the requirements of the system restrictions below. Mount the weda app object in the onLaunch function of app.js (add code, this.app = wedaApp), After mounting, sub-packages and other modules can get the weda app object by const {app} = getApp().
  • Code package as a sub-module: It is necessary to ensure that the content is an independent small program application directory, that is, the miniprogramRoot directory. The overall project will be placed in the /packages/${subapp.name} path, so the original file references and the absolute path used in the route jump may need to be corrected, and the relative path relationship of the files in the package will not change. On the whole, it is required that the final modified code package is a code package in the small program sub-package mode, and an app.json declares the page list in the package. For example: the content of app.json in subpackage sub is:
{
  "pages": [
    "pages/index/index",
    "pages/checkbox/index",
    "pages/switch/index",
    "pages/slider/index"
  ]
}

Then the configuration will be added in the generated complete small program app.json

{
  "subpackages": [
    {
      "root": "packages/sub",
      "pages": [
        "pages/index/index",
        "pages/checkbox/index",
        "pages/switch/index",
        "pages/slider/index"
      ]
    }
  ]
}

Use low-code editing main/sub-modules: the system will automatically generate relevant code, no need to care too much about the reference relationship, only the business logic of the application itself, when the current page jumps to the page of the main package, or the sub-package Page.

main sub-module interaction

The widget application state is divided into global state and page-level state. The global state is shared by the entire application, and the page-level state is independent of each page. Therefore, when data interaction between the main sub-modules is required, the global state should be used for proxy storage. In low code, you can get the app object and get/assign the global variables on it. In the code package type module, you can get the app object by using const {app} = getApp() to get/assign the value Variables, and methods such as using data sources.

The main module page path is /pages/${page.id}/index, and the sub-module page path is:

/packages/${subapp.name}/pages/${page.id}/index。

It is necessary to specify the corresponding template address when processing the route jump.

Note the following restrictions:

  • Each application contains 1 main module and no more than 5 sub-modules. When the main sub-module contains at least one low-code editing type module, it can be mixed and constructed on the widget platform.
  • When the main module is a code package type, it is a complete mini program application. After decompression, the root directory needs to contain the project.config.json file, where the mini program application root directory (miniprogramRoot) is declared. The directory contains app.json, app.js, app.wxss and other application-level files. At the same time, packages, common, app, materials, and lowcode are reserved directories. When generating applications with low-code modules, low-code will be generated in this directory. Required documents.
  • When the submodule is a code package type, it must be an independent small program application directory, namely miniprogramRoot. After decompression, the root directory contains application-level files such as app.json, and its content will be merged with the main module configuration generated by low-code.
  • Application-level low-code and variable management can only be done in the main application. The low-code editing sub-modules can be viewed in the editor, but definitions, declarations, additions, deletions, and editing cannot be performed.

immediately experience the micro-ride low code

Website: https://console.cloud.tencent.com/lowcode/ PC access


CloudBase云开发
425 声望438 粉丝

云开发(Tencent CloudBase,TCB)是云端一体化的后端云服务 ,采用 serverless 架构,免去了移动应用构建中繁琐的服务器搭建和运维。同时云开发提供的静态托管、命令行工具(CLI)、Flutter SDK 等能力极大的降...