app.json
文件用来对 TMF 小程序进行全局配置,可以通过设置来决定页面文件的路径、窗口表现、网络超时时间以及多 tab 等功能。app.json
:{"pages": ["pages/index/index", "pages/logs/index"],"window": {"navigationBarTitleText": "Demo"},"tabBar": {"list": [{"pagePath": "pages/index/index","text": "首页"},{"pagePath": "pages/logs/logs","text": "日志"}]},"networkTimeout": {"request": 10000,"downloadFile": 10000},"debug": true,"navigateToMiniProgramAppIdList": ["tmfq0nbl3hxxlv2w7u"],"groupIdList":["123456","34356576","457658769"]}
属性 | 类型 | 必填 | 描述 |
pages | String Array | 是 | 页面路径列表 |
window | Object | 否 | 全局的默认窗口表现 |
tabBar | Object | 否 | 底部 tab 栏表现 |
networkTimeout | Object | 否 | 网络超时时间 |
requiredBackgroundModes | String Array | 否 | 需要后台使用的能力,如音乐播放 |
navigateToMiniProgramAppIdList | String Array | 否 | |
permission | Object | 否 | 小程序接口权限相关设置 |
darkmode | Boolean | 否 | 获取当前手机是否为夜间模式 |
.json
,.js
,.wxml
,.wxss
四个文件进行处理。├── app.js├── app.json├── app.wxss├── pages│ │── index│ │ ├── index.wxml│ │ ├── index.js│ │ ├── index.json│ │ └── index.wxss│ └── logs│ ├── logs.wxml│ └── logs.js└── utils
app.json
中写:{"pages": ["pages/index/index", "pages/logs/logs"]}
属性 | 类型 | 默认值 | 描述 |
navigationBarBackgroundColor | HexColor | #000000 | 导航栏背景颜色,如 #000000 |
navigationBarTextStyle | String | white | 导航栏标题颜色,仅支持 black / white |
navigationBarTitleText | String | - | 导航栏标题文字内容 |
navigationStyle | String | default | 导航栏样式,仅支持以下值: default:默认样式; custom:自定义导航栏,只保留右上角胶囊按钮; hide:自定义导航栏,可以支持隐私导航栏和胶囊按钮。 |
backgroundColor | HexColor | #ffffff | 窗口的背景色 |
backgroundTextStyle | String | dark | 下拉 loading 的样式,仅支持 dark / light |
backgroundColorTop | String | #ffffff | 顶部窗口的背景色,仅 iOS 支持 |
backgroundColorBottom | String | #ffffff | 底部窗口的背景色,仅 iOS 支持 |
enablePullDownRefresh | Boolean | false | |
customNavigateBack | Boolean | false | 是否需要拦截页面的默认返回(单击 tabBar 返回或侧滑或 back 键返回)结合Page.onCustomBack 使用 |
pageOrientation | String | portrait |
navigationStyle
{"window": {"navigationBarBackgroundColor": "#ffffff","navigationBarTextStyle": "black","navigationBarTitleText": "TMF接口功能演示","backgroundColor": "#eeeeee","backgroundTextStyle": "light"}}
属性 | 类型 | 必填 | 默认值 | 描述 |
color | HexColor | 是 | - | tab 上的文字默认颜色,仅支持十六进制颜色 |
selectedColor | HexColor | 是 | - | tab 上的文字选中时的颜色,仅支持十六进制颜色 |
backgroundColor | HexColor | 是 | - | tab 的背景色,仅支持十六进制颜色 |
borderStyle | String | 否 | black | tabbar上边框的颜色, 仅支持 black / white |
list | Array | 是 | - | tab 的列表,最少2个 tab、最多5个 tab |
position | String | 否 | bottom | tabBar的位置,仅支持 bottom / top |
custom | Boolean | 否 | false |
属性 | 类型 | 必填 | 说明 |
pagePath | String | 是 | 页面路径,必须在 pages 中先定义 |
text | String | 是 | tab 上按钮文字 |
iconPath | String | 否 | 图片路径,icon 大小限制为40kb,建议尺寸为 81px * 81px,不支持网络图片 |
selectedIconPath | String | 否 | 选中时的图片路径,icon 大小限制为 40kb,建议尺寸为 81px * 81px,不支持网络图片。当 postion 为 top 时,不显示 icon。 |
属性 | 类型 | 必填 | 默认值 | 描述 |
request | Number | 否 | 60000 | |
uploadFile | Number | 否 | 60000 |
audio
:后台音乐播放。{"pages": ["pages/index/index"],"requiredBackgroundModes": ["audio"]}
属性 | 类型 | 必填 | 默认值 | 描述 |
scope.userLocation | PermissionObject | 否 | - | 位置相关权限声明 |
属性 | 类型 | 必填 | 默认值 | 说明 |
desc | string | 是 | - | 小程序获取权限时展示的接口中文用途说明。最长80个字符 |
desc-en | string | 是 | - | 小程序获取权限时展示的接口英文用途说明。最长80个字符 |
desc-adesc-ar | string | 是 | - | 小程序获取权限时展示的接口阿语用途说明。最长80个字符 |
{"pages": ["pages/index/index"],"permission": {"scope.userLocation": {"desc": "你的位置信息将用于小程序位置接口的效果展示","desc-en": "where are you? do you know","desc-ar":"انا من السعودية"}}}
{"navigationBarBackgroundColor": "#ffffff","navigationBarTextStyle": "black","navigationBarTitleText": "TMF接口功能演示","backgroundColor": "#eeeeee","backgroundTextStyle": "light"}
属性 | 类型 | 默认值 | 描述 |
navigationBarBackgroundColor | HexColor | #000000 | 导航栏背景颜色,如 #000000 |
navigationBarTextStyle | String | white | 导航栏标题颜色,仅支持 black / white |
navigationBarTitleText | String | - | 导航栏标题文字内容 |
navigationStyle | String | default | 导航栏样式,仅支持以下值: default:默认样式; custom:自定义导航栏,只保留右上角胶囊按钮; hide:自定义导航栏,可以支持隐私导航栏和胶囊按钮。 |
backgroundColor | HexColor | #ffffff | 窗口的背景色 |
backgroundTextStyle | String | dark | 下拉 loading 的样式,仅支持 dark / light |
backgroundColorTop | String | #ffffff | 顶部窗口的背景色,仅 iOS 支持 |
backgroundColorBottom | String | #ffffff | 底部窗口的背景色,仅 iOS 支持 |
enablePullDownRefresh | Boolean | false | |
pageOrientation | String | portrait | 屏幕旋转设置,支持 auto / portrait / landscape 详见 响应显示区域变化 |
本页内容是否解决了您的问题?