目录

"js" Tag

The "js" tag contains the instance name, window style, and page route information.

Tag Data Type Default Value Mandatory Description
name String default Yes Name of the JavaScript instance.
pages Array - Yes Route information. For details, see "pages".
window Object - No Window information. For details, see "window".

The "name", "window", and "pages" tags are configured in the "js" tag of the config.json file.

pages

"pages" defines the route information of each page. Each page consists of the page path and page name. The following is an example:

{
    // ...
    "pages": [
        "pages/index/index",
        "pages/detail/detail"
    ]
    // ...
}
  • The first page in the pages list is the homepage, also referred to as the entry, of the application.

  • The page name should not be a component name, for example, text.hml or button.hml.

window

"window" defines window-related configurations. You can configure screen adaptation in either of the following ways:

Attribute Type Mandatory Default Value Description
designWidth number No

720

Logical screen width, which is a reference value for page design. The actual display width is scaled at the ratio of the value to the device width.
autoDesignWidth boolean No false

Whether to automatically calculate the baseline width for page design.

The value true means to automatically calculate the baseline width for page design, and false means the opposite.

If it is set to true, the designWidth attribute becomes invalid. The baseline width is calculated based on the device width and screen density.

The following is an example.

{
    // ...
    "window": {
        "designWidth": 720,
        "autoDesignWidth": false
    }
    // ...
}

Example

{
  "app": {
    "bundleName": "com.example.player",
    "version": {
        "code": 1,
        "name": "1.0"
    },
    "vendor": "example"
  },
  "module": {
      // ...
      "js": [
      {
          "name": "default",
          "pages": [
              "pages/index/index",
              "pages/detail/detail"
          ],
          "window": {
              "designWidth": 720,
              "autoDesignWidth": false
          }
      }
      ],
      "abilities": [
      {
          // ...
      }
    ]
  }
}