uniapp自定义头部导航怎么实现?

一、在pages.json文件里边写上自定义属性

"navigationStyle": "custom"

二、在对应的index页面写上以下:

<view :style="{ height: headheight + 'px', backgroundColor: '#24B7FF', zIndex: 99, position: 'fixed', top: '0px', width: '100%' }">
</view>
<view class="head" :style="{ top: headheight + 'px', backgroundColor: '#24B7FF' }">
	<view>新乡市</view>
</view>
<view style="height: 100rpx;"></view>

三、在script标签的return里边写上

headheight: '',

四、在onLoad()周期里面写上

const systemInfo = uni.getSystemInfoSync();
const windowHeight = systemInfo.statusBarHeight;
this.headheight = windowHeight;

五、style

.head {
		display: flex;
		justify-content: center;
		align-items: center;
		position: fixed;
		height: 100rpx;
		width: 100%;
		z-index: 99;
	}

效果:

相关推荐

  1. uniapp定义头部导航

    2023-12-25 00:20:01       34 阅读
  2. Uniapp定义导航

    2023-12-25 00:20:01       57 阅读
  3. uniapp——定义导航栏的封装

    2023-12-25 00:20:01       61 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2023-12-25 00:20:01       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2023-12-25 00:20:01       101 阅读
  3. 在Django里面运行非项目文件

    2023-12-25 00:20:01       82 阅读
  4. Python语言-面向对象

    2023-12-25 00:20:01       91 阅读

热门阅读

  1. overtureDNS使用介绍

    2023-12-25 00:20:01       63 阅读
  2. 【算法题】7. 整数反转

    2023-12-25 00:20:01       72 阅读
  3. Python-os.path 学习

    2023-12-25 00:20:01       52 阅读
  4. 正则表达式

    2023-12-25 00:20:01       51 阅读
  5. jQuery 实现带手柄自由调整页面大小的功能

    2023-12-25 00:20:01       69 阅读
  6. GO设计模式——20、备忘录模式(行为型)

    2023-12-25 00:20:01       68 阅读
  7. 功能测试方法总结之增删查改

    2023-12-25 00:20:01       64 阅读
  8. 通信原理 | 信号

    2023-12-25 00:20:01       63 阅读
  9. Python---类(初始化函数)

    2023-12-25 00:20:01       63 阅读
  10. @RequestBody详解:用于获取请求体中的Json格式参数

    2023-12-25 00:20:01       76 阅读
  11. C语言的if语句(三 )

    2023-12-25 00:20:01       61 阅读