页面配置

每个小程序的页面也可以使用 .json 文件来对本页面的窗口表现进行配置。

页面的配置只能设置 app.json 中部分 window 配置项的内容,页面中配置项会覆盖 app.jsonwindow 中相同的配置项,可配置的选项如下:

键值 说明
navigationBar 用于设置小程序的状态栏的 UI 配置
        textColor 导航栏标题颜色,值为十六进制颜色值
        backgroundColor 导航栏背景颜色,值为十六进制颜色值
        titleText 导航栏标题文字
usingComponents 页面自定义组件配置
keepAlive 用于设置是否缓存页面数据

说明:页面配置中只能设置 app.json 中 window 对应的配置项,以决定本页面的窗口表现,所以无需写 window 这个属性。

示例代码

以下为 pages/about/index.json 的配置示例

{
"navigationBar": {
"textColor": "#000000",
"backgroundColor": "#ffffff",
"titleText": "关于"
},
"usingComponents": {
"demoComp": "../../components/demo/index", // 引入自定义组件
"F2": "@antv/f2" //引入第三方组件
},
"keepAlive": true // 缓存页面
}
以下是对第三方组件 `F2` 的引用

const chart = new F2.Chart({
id: 'c1',
width: 375,
height: 265,
pixelRatio: window.devicePixelRatio
});
以下是对一个三方组件 `demoComp` 的引用

<div>
<demoComp></demoComp>
</div>
  1. 1. 页面配置
    1. 1.1. 示例代码