在page.json里面配置顶部和底部tabbar
{
"pages": [ //pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages
{
"path": "pages/index/index",
"style": {
"navigationBarTitleText": "首页"
}
},
{
"path": "pages/news/news",
"style": {
"navigationBarTitleText": "新闻"
}
}
],
"globalStyle": {
"navigationBarTextStyle": "black",
"navigationBarTitleText": "uni-app",
"navigationBarBackgroundColor": "#007AFF",
"backgroundColor": "#007AFF",
"enablePullDownRefresh":true//全局下拉刷新
},
"tabBar": {
"color": "#7A7E83",//默认字体颜色
"selectedColor": "#3cc51f",//选中颜色
"borderStyle": "black",//边框线
"backgroundColor": "#ffffff",//背景颜色
"height": "50px",//高
"fontSize": "10px",
"iconWidth": "24px",
"spacing": "3px",
"list": [{
"pagePath": "pages/index/index",
"text": "首页"
}, {
"pagePath": "pages/news/news",
"text": "新闻"
}],
"midButton": {
"width": "80px",
"height": "50px",
"text": "文字"
}
},
"condition" : { //模式配置,仅开发期间生效(启动配置)
"current": 0, //当前激活的模式(list 的索引项)
"list": [
{
"name": "", //模式名称
"path": "", //启动页面,必选
"query": "" //启动参数,在页面的onLoad函数里面得到
}
]
}
}
路由的跳转因为用的是小程序里面的一些东西,路由和小程序里面相似。
主页之间跳转需要注意的地方:(尽量不要用相对路径,使用绝对路径)
TabBar页面之间跳转使用属性:open-type:switchTab跳转。
open-type=“navigate”:非tabBar页面跳转