赞
踩
uni-app
中的页面,通常会保存在工程根目录下的pages
目录下。
每次新建页面,均需在pages.json
中配置pages列表;未在pages.json -> pages
中配置的页面,uni-app
会在编译阶段进行忽略。
通过HBuilderX
开发 uni-app
项目时,在 uni-app
项目上右键“新建页面”
,HBuilderX会自动在pages.json
中完成页面注册,开发更方便。
同时,HBuilderX 还内置了常用的页面模板(如图文列表、商品列表等),选择这些模板,可以大幅提升你的开发效率。
- "tabBar": {
- "color": "#7A7E83",
- "selectedColor": "#435950",
- "borderStyle": "black",
- "backgroundColor": "#ffffff",
- "list": [{
- "pagePath": "pages/home/home",
- "iconPath": "static/icons/home.png",
- "selectedIconPath": "static/icons/home-active.png",
- "text": "首页"
- }, {
- "pagePath": "pages/kind/kind",
- "iconPath": "static/icons/kind.png",
- "selectedIconPath": "static/icons/kind-active.png",
- "text": "分类"
- }, {
- "pagePath": "pages/find/find",
- "iconPath": "static/icons/find.png",
- "selectedIconPath": "static/icons/find-active.png",
- "text": "发现"
- }, {
- "pagePath": "pages/user/user",
- "iconPath": "static/icons/mine.png",
- "selectedIconPath": "static/icons/mine-active.png",
- "text": "我的"
- }]
- }

如果应用是一个多 tab 应用,可以通过 tabBar 配置项指定一级导航栏,以及 tab 切换时显示的对应页。
在 pages.json 中提供 tabBar 配置,不仅仅是为了方便快速开发导航,更重要的是在App和小程序端提升性能。在这两个平台,底层原生引擎在启动时无需等待js引擎初始化,即可直接读取 pages.json 中配置的 tabBar 信息,渲染原生tab。
Tips
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。