当前位置:网站首页>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>
边栏推荐
- 【二叉树-困难】124. 二叉树中的最大路径和
- Data Governance (5): Metadata Management
- 2022.8.8 Exam Travel Summary
- Introduction and application of quantitative trading strategies
- Research on IC enterprises
- Redis - String|Hash|List|Set|Zset数据类型的基本操作和使用场景
- “双枪”木马病毒的进化史
- 剑指offer专项突击版第25天
- 【8.8】代码源 - 【不降子数组游戏】【最长上升子序列计数(Bonus)】【子串(数据加强版)】
- The IDEA to automatically generate the serialVersionUID
猜你喜欢
随机推荐
实例046:打破循环
liunx PS1 设置
基于误差状态的卡尔曼滤波ESKF
高精度加法
Arrays类
Difference Between Data Mining and Data Warehousing
“双枪”木马病毒的进化史
二进制与内存
2022.8.8考试从记忆中写入(memory)题解
ArcGIS Advanced (1) - Install ArcGIS Enterprise and create an sde library
实例047:函数交换变量
2022.8.9 Exam Cube Sum--1100 Question Solutions
【Kali安全渗透测试实践教程】第8章 Web渗透
MySQL:你做过哪些MySQL的优化?
[Red Team] ATT&CK - Auto Start - Registry Run Key, Startup Folder
【Image Classification】2022-ResMLP
yolov5+usb相机
plsql 查询数据库操作历史记录(Ctrl + e)
实例045:求和
PostgreSQL相关语法及指令示例