目录

Project Configuration Using app.json

The app.json file is used to describe the configuration information of the entire project. The following shows a basic configuration example:

{
  "pages": ["page/index/index"],
  "window": {
    "navigationBarTitleText": "ascf",
    "navigationBarTextStyle": "black"
  }
}

The table below lists the properties of app.json.

Node Attribute Type Default Value Mandatory Description
- entryPagePath string - No Home page, which is the first item in pages to start. The page path parameter is not supported.
- pages string[] - Yes List of page paths.
- window Object - No Global default window.
- tabBar Object - No Tab bar at the bottom.
- subpackages Object[] - No

Subpackage structure. After compilation, the pages field is reserved, and other fields are aligned accordingly.

"subpackages": [{"resource": "packageMore","root": "packageMore""pages": ["more/more"]}]

- usingComponents Object - No Configuration of global custom components.
- resolveAlias Object - No

Custom module mapping rule.

Dependency: ASCF Toolkit version 1.0.4 or later

- lazyCodeLoading string - No

On-demand code injection for custom components. Currently, only requiredComponents is supported.

Since: 1.0.13

Dependency: ASCF Toolkit version 1.0.6 or later

- requiredBackgroundModes string[] - No

Array of capabilities that are required to run in the background. Currently, the following options are supported:

audio: music playback in the background.

- visualEffectInBackground string none No

Whether to hide the page content for user privacy protection when the app is switched to the system background. The options are hidden and none.

Since: 2.0.1

window navigationBarBackgroundColor HexColor #ffffff No Background color of the navigation bar.
window navigationBarTextStyle string black No

Title color of the navigation bar.

For API version 12, this parameter can be set to black or white only when navigationStyle is set to custom. In other cases, only black is available.

For API version 13 or later, the value can be black or white.

window navigationBarTitleText string - No Title text of the navigation bar.
window navigationStyle string default No

Navigation bar style. The options are as follows:

- default: default style.

- custom: custom style. Only the capsule button in the upper right corner is retained.

window backgroundColor HexColor #ffffff No Background color of the window.
window backgroundTextStyle string dark No Background text style of pull-down loading. Only dark and light are available.
window onReachBottomDistance number 50 No Distance from the bottom of the page when the pull-up event is triggered, in pixels.
window enablePullDownRefresh boolean false No Whether to enable global pull-down refresh.
tabBar color HexColor #ffffff Yes Default text color on tabs. Only the color represented by a hexadecimal value is supported.
tabBar selectedColor HexColor #000000 Yes Color of the selected text on tabs. Only the color represented by a hexadecimal value is supported.
tabBar backgroundColor HexColor #ffffff Yes Background color of tabs. Only the color represented by a hexadecimal value is supported.
tabBar position string bottom No Position of the tab bar. Only bottom and top are available.
tabBar borderStyle string black No Color of the top border of the tabBar component. The value can only be black or white.
tabBar list Array - Yes List of tabs.
tabBar custom boolean false No

Whether to enable the custom tab bar.

Since: 1.0.10

tabBar.list pagePath string - Yes Page path, which must be defined in pages.
tabBar.list text string - Yes Button text on a tab.
tabBar.list iconPath string - No Icon path. The maximum size of an icon is 40 KB. The recommended size is 81 px × 81 px. Online images are not supported.
tabBar.list selectedIconPath string - No Selected icon path. The maximum size of an icon is 40 KB. The recommended size is 81 px × 81 px. Online images are not supported.

resolveAlias

The resolveAlias configuration item can be used to customize the mapping rule of the module path.

After the configuration is complete, the module path in require is matched based on the configured mapping rule and then converted to the corresponding configuration path.

If multiple rules are matched, the longest rule is used.

{
  "resolveAlias": {
    "~/*": "/*",
    "~/index/*": "index/*",
    "@utils/*": "utils/*",
    "subBView/*": "subpackageB/view/*"
  }
}

resolveAlias is used for path matching. The key and value must end with /*.

After the preceding path mapping rule is configured, the following matching and conversion are performed: