当前位置:网站首页>uni-app自定义导航栏
uni-app自定义导航栏
2022-08-10 02:28:00 【程序猿向前跑】
有时我们需要对导航栏进行自定义,接下来就是对uni-app进行代码的编写
对于一些不是很复杂的顶部导航,当然使用原生导航栏实现是最佳选择
uni-app原生导航栏也能实现一些顶部自定义按钮+搜索框,只需在page.json里面做一些配置即可。设置app-plus,不过目前暂支持H5、App端,不支持小程序。
将navigationStyle设为custom或titleNView设为false时,原生导航栏不显示,这时就能自定义导航栏
"globalStyle": {
"navigationStyle": "custom" }
<script>
import Vue from 'vue'
export default {
onLaunch: function() {
uni.getSystemInfo({
success: function(e) {
// #ifndef MP
Vue.prototype.StatusBar = e.statusBarHeight;
if (e.platform == 'android') {
Vue.prototype.CustomBar = e.statusBarHeight + 50;
} else {
Vue.prototype.CustomBar = e.statusBarHeight + 45;
};
// #endif
// #ifdef MP-WEIXIN
Vue.prototype.StatusBar = e.statusBarHeight;
let custom = wx.getMenuButtonBoundingClientRect();
Vue.prototype.Custom = custom;
Vue.prototype.CustomBar = custom.bottom + custom.top - e.statusBarHeight + 4;
// #endif
// #ifdef MP-ALIPAY
Vue.prototype.StatusBar = e.statusBarHeight;
Vue.prototype.CustomBar = e.statusBarHeight + e.titleBarHeight;
// #endif
}
});
},
onShow: function() {
console.log('App Show')
},
onHide: function() {
console.log('App Hide')
}
}
</script>
<style lang="scss">
@import "colorui/main.css";
@import "colorui/icon.css";
@import "uview-ui/index.scss";
</style>
边栏推荐
猜你喜欢
随机推荐
Pagoda server PHP+mysql web page URL jump problem
【红队】ATT&CK - 自启动 - 注册表运行键、启动文件夹
HRnet
ArcGIS Advanced (1) - Install ArcGIS Enterprise and create an sde library
2022年立下的flag完成情况
浅写一个下拉刷新组件
2020.11.22考试哥德巴赫猜想题解
[Red Team] ATT&CK - Auto Start - Registry Run Key, Startup Folder
《GB39707-2020》PDF download
P1564 Worship
MySQL:你做过哪些MySQL的优化?
Example 048: Number ratio size
web crawler error
芯片加速器 Accelerator
Deep Learning (5) CNN Convolutional Neural Network
In automated testing, test data is separated from scripts and parameterized methods
2022.8.9 Exam arrangement and transformation--1200 questions solution
电子产品结构设计中的电磁兼容性(EMC)设计
flink 12 源码编译及使用idea运行、debug
2022.8.9 Exam Travel Summary