全局/局部tabBar
需求:底部导航栏
tabBar有两种方式:1.设置全局导航栏,页面变化,导航栏不变。2.设置局部导航栏,随着页面变化而变化
比如导航栏有三个按钮,全局导航栏是设置三个页面,点击一个按钮显示一个页面。
局部导航栏是设置三个页面,每个页面的底部导航栏都一样,是来进行刷新。
全局tabBar
比如导航栏有三个按钮,全局导航栏是设置三个页面,点击一个按钮显示一个页面
优点:便于管理
app.json
"tabBar": {"color": "#8c8c8c","selectedColor": "#f4645f","backgroundColor": "white","list": [{"pagePath": "pages/index/index","text": "开始"},{"pagePath": "pages/aboutwe/index","text": "分类"}],"position": "bottom"}}
局部tabBar
比如三个按钮,局部导航栏是设置三个页面,每个页面的底部导航栏都一样,是来进行刷新
缺点:不好管理
tabBar添加背景图片
iconPath设置的是开始时显示的图标,selectedIconPath是选中时显示的图标
[IconPath可以不写]
list: [{pagePath: 'pages/index/index',iconPath:'assets/6.png',selectedIconPath:'assets/6.png',text: '首页'},
问题和细节
问题
一开始是在dist/app.json内修改的,terminal终端编译后就消失了。
因为所有的程序都是在src内添加的,编译后才能保存在dist,直接在dist内添加是无效的
src/app.js
config = {pages: ['pages/index/index','pages/user/index','pages/order/index','pages/aboutwe/index','pages/regular/index','pages/information/index','pages/read/index','pages/booklist/index','pages/trueorder/index'],window: {backgroundTextStyle: 'light',navigationBarBackgroundColor: '#fff',navigationBarTitleText: 'WeChat',navigationBarTextStyle: 'black'},tabBar: {color: '#8c8c8c',selectedColor: '#f4645f',backgroundColor: 'white',list: [{pagePath: 'pages/index/index',text: '首页'},{pagePath: 'pages/trueorder/index', text: '分类'}],position: 'bottom'} }
细节
不深陷程序中,脑海中始终贯彻主线。切记!切记!切记!
