「这是我参与11月更文挑战的第1天,活动详情查看:2021最后一次更文挑战」
这是官网描述的:✈️
"tabBar": {
"color": "#7A7E83",
"selectedColor": "#007AFF",
"borderStyle": "#f7fcfe",
"spacing":"1px",
"position":"bottom",
"backgroundColor": "#f7fcfe",
// "fontSize": "15px",
"list": [{
"pagePath": "pages/tabBar/Home/Home",
// "iconPath": "static/component.png",
// "selectedIconPath": "static/componentHL.png",
"text": "首页"
},
{
"pagePath": "pages/tabBar/component/component",
"iconPath": "static/component.png",
"selectedIconPath": "static/componentHL.png",
"text": "内置组件"
},
{
"pagePath": "pages/tabBar/extUI/extUI",
"iconPath": "static/extui.png",
"selectedIconPath": "static/extuiHL.png",
"text": "扩展组件"
}, {
"pagePath": "pages/tabBar/template/template",
"iconPath": "static/template.png",
"selectedIconPath": "static/templateHL.png",
"text": "模板"
}
],
"midButton": {
"pagePath": "pages/tabBar/API/API",
"iconPath": "static/icon/record.png",
"width": "70px",
"height": "69px",
"iconWidth": "50px",
"text": "发布"
}
}
图片可以去iconfont中下载✈️ [📢]图片大小最好80*80 并且不大于40kb 看一下效果
如果不需要图标,去掉此配置项即可。
App.vue文件夹中加入监听事件
<script>
export default {
// 初始化生命周期
onLaunch: function() {
// 监听事件
uni.onTabBarMidButtonTap(() => {
// 注意路由带 /
uni.navigateTo({
url: '/pages/publish/publish',
});
})
},
onShow: function() {
console.log('App Show')
},
onHide: function() {
console.log('App Hide')
}
}
</script>
现在点击按钮就会跳转。这个跳转的路由对应的页面一定要在pages.json中的page配置项中注册。