tabBar
1 创建 tabBar 分支
运行如下的命令,基于 master 分支在本地创建 tabBar 子分支,用来开发和 tabBar 相关的功能:
git checkout -b tabbar
查看分支
git branch
2 创建 tabBar 页面
在 pages
目录中,创建首页(home)、分类(cate)、购物车(cart)、我的(my) 这 4 个 tabBar 页面。在 HBuilderX 中,可以通过如下的两个步骤,快速新建页面:
- 在
pages
目录上鼠标右键,选择新建页面 - 在弹出的窗口中,填写页面的名称、勾选 scss 模板之后,点击创建按钮。截图如下:
3 配置 tabBar 效果
-
将
资料
目录下的static 文件夹
拷贝一份,替换掉项目根目录中的static 文件夹
-
修改项目根目录中的
pages.json
配置文件,新增tabBar
的配置节点如下:{ "tabBar": { "selectedColor": "#C00000", "list": [ { "pagePath": "pages/home/home", "text": "首页", "iconPath": "static/tab_icons/home.png", "selectedIconPath": "static/tab_icons/home-active.png" }, { "pagePath": "pages/cate/cate", "text": "分类", "iconPath": "static/tab_icons/cate.png", "selectedIconPath": "static/tab_icons/cate-active.png" }, { "pagePath": "pages/cart/cart", "text": "购物车", "iconPath": "static/tab_icons/cart.png", "selectedIconPath": "static/tab_icons/cart-active.png" }, { "pagePath": "pages/my/my", "text": "我的", "iconPath": "static/tab_icons/my.png", "selectedIconPath": "static/tab_icons/my-active.png" } ] } }
4 删除默认的 index 首页(否则加载不出tabBar)
- 在 HBuilderX 中,把
pages
目录下的index首页文件夹
删除掉 - 同时,把
page.json
中记录的index 首页
路径删除掉
5 修改导航条的样式效果
-
打开
pages.json
这个全局的配置文件 -
修改
globalStyle
节点如下:{ "globalStyle": { "navigationBarTextStyle": "white", "navigationBarTitleText": "青橙商城", "navigationBarBackgroundColor": "#C00000", "backgroundColor": "#FFFFFF" } }
6 分支的提交与合并
- 将本地的 tabbar 分支进行本地的 commit 提交:
git add .
git commit -m "完成了 tabBar 的开发"
- 将本地的 tabbar 分支推送到远程仓库进行保存:
git push -u origin tabbar
git报错fatal: unable to access ‘https://github.com/.......‘: OpenSSL SSL_read: Connection was reset, e
报错fatal: unable to access 'github.com/tomcat-echo…': Failed to connect to github.com port 443 after 21052 ms: Couldn't connect to server
解决:blog.csdn.net/weixin_4444… 提示! [rejected] master -> master (non-fast-forward) blog.csdn.net/zyz00000000… 3. 将本地的 tabbar 分支合并到本地的 master 分支:
git checkout master
git merge tabbar
- 删除本地的 tabbar 分支:
git branch -d tabbar
- 开启掘金成长之旅!这是我参与「掘金日新计划 · 2 月更文挑战」的第 12 天,点击查看活动详情