微信小程序—标题栏
<template>
<view :style="{paddingTop: statusBarHeight + 'px',background:bg}" class="box">
<view :style="{width: titleBarWidth + 'px', height: titleBarHeight + 'px'}">
<slot name="parent" :menuButtonHeight="menuButtonHeight" :titleBarHeight="titleBarHeight"></slot>
</view>
</view>
</template> <script>
export default {
name: "titleBar",
data() {
return {
statusBarHeight: 0,
menuButtonHeight: 0,
titleBarWidth: 0,
titleBarHeight: 0,
}
},
props: ['bg'],
created() {
this.statusBarHeight = uni.getStorageSync("statusBarHeight");
this.menuButtonHeight = uni.getStorageSync("menuButtonHeight");
this.titleBarWidth = uni.getStorageSync("titleBarWidth");
this.titleBarHeight = uni.getStorageSync("titleBarHeight");
},
onReady() {
uni.setStorageSync('statusBarHeight', uni.getSystemInfoSync().statusBarHeight);
uni.setStorageSync('menuButtonHeight', uni.getMenuButtonBoundingClientRect().height);
uni.setStorageSync('titleBarWidth', uni.getSystemInfoSync().windowWidth - uni.getMenuButtonBoundingClientRect()
.width -
(uni.getSystemInfoSync().windowWidth - uni.getMenuButtonBoundingClientRect().right) * 2);
uni.setStorageSync('titleBarHeight', (uni.getMenuButtonBoundingClientRect().top - uni.getStorageSync(
"statusBarHeight")) * 2 + uni.getStorageSync("menuButtonHeight"));
if (!this.menuButtonHeight) {
this.statusBarHeight = uni.getStorageSync("statusBarHeight");
this.menuButtonHeight = uni.getStorageSync("menuButtonHeight");
this.titleBarWidth = uni.getStorageSync("titleBarWidth");
this.titleBarHeight = uni.getStorageSync("titleBarHeight");
}
}
}
</script> <style>
.box {
position: sticky;
top: 0rpx;
z-index: 999;
}
</style>
效果:

<titleBar bg="#f6f6f6">
<template v-slot:parent>
<view class="xbox">
服务内容
</view>
</template>
</titleBar>
.xbox{
height: 100%;
display: flex;
align-items: center;
justify-content: center;
}
微信小程序—标题栏的更多相关文章
- 微信小程序教程系列
微信小程序教程系列 来源: https://blog.csdn.net/michael_ouyang/article/details/56846185 相关连接:http://blog.c ...
- [转]微信小程序之购物车 —— 微信小程序实战商城系列(5)
本文转自:http://blog.csdn.net/michael_ouyang/article/details/70755892 续上一篇的文章:微信小程序之商品属性分类 —— 微信小程序实战商城 ...
- [转]微信小程序之购物数量加减 —— 微信小程序实战商城系列(3)
本文转自:http://blog.csdn.net/michael_ouyang/article/details/70194144 我们在购买宝贝的时候,购物的数量,经常是我们需要使用的,如下所示: ...
- [转]微信小程序之加载更多(分页加载)实例 —— 微信小程序实战系列(2)
本文转自;http://blog.csdn.net/michael_ouyang/article/details/56846185 loadmore 加载更多(分页加载) 当用户打开一个页面时,假设后 ...
- 微信小程序导航:官方工具+精品教程+DEMO集合(1月7更新)
1:官方工具:https://mp.weixin.qq.com/debug/w ... tml?t=14764346784612:简易教程:https://mp.weixin.qq.com/debug ...
- 《微信小程序七日谈》- 第四天:页面路径最多五层?导航可以这么玩
<微信小程序七日谈>系列文章: 第一天:人生若只如初见: 第二天:你可能要抛弃原来的响应式开发思维: 第三天:玩转Page组件的生命周期: 第四天:页面路径最多五层?导航可以这么玩 微信小 ...
- 微信小程序开发常见问题分析
距离微信小程序内测版发布已经有十几天的时间了,网上对微信小程序的讨论也异常火爆,从发布到现在微信小程序一直占领着各种技术论坛的头条,当然各种平台也对微信小程序有新闻报道,毕竟腾讯在国内影响力还是很大的 ...
- 官方问答--微信小程序常见FAQ (17.8.21-17.8.27)
给提问的开发者的建议:提问之前先查询 文档.通过社区右上角搜索搜索已经存在的问题. 写一个简明扼要的标题,并且正文描述清楚你的问题. 提交 BUG:需要带上基础库版本号,设备信息(iOS, Andro ...
- 微信小程序之下拉加载和上拉刷新
微信小程序下拉加载和上拉刷新两种实现方法 方法一:onPullDownRefresh和onReachBottom方法实现小程序下拉加载和上拉刷新 首先要在json文件里设置window属性 ...
- 微信小程序对接串口摄像头
串口摄像头由树莓派控制,代码如下: # _*_ coding:utf-8 import serial import time import traceback import pycurl import ...
随机推荐
- MySQL表操作(上篇)
1.存储引擎的介绍 (1)存储引擎 1.什么是存储引擎? mysql中建立的库===>文件夹 库中建立的表===>文件 现实生活中我们用来存储数据的文件有不同的类型,每种文件类型对应各自不 ...
- Oversampling Techniques
ADC Operation Improving ADC Resolution 总结 根据奈奎斯特采样定理,Fsample >= 2 * Fsignal 在频域中,过采样能够降低白噪声功率谱密度 ...
- 使用centos8.5配置一台YUM源服务器
公司的生产环境部署的Centos8.5, 现在已经EOL了, 为了给生产和测试机继续提供yum/dnf服务, 特意在公司的内部机房部署了一套本地yum源. 环境:centos 8.5 1. 下载镜像 ...
- centos8.5安装kvm及kvm虚拟机的端口映射问题
1.安装KVM grep -Ei 'vmx|svm' /proc/cpuinfo|more #查看硬件是否支持虚拟化 yum install -y virt-* libvirt qemu-img ...
- Excel 的盒须图 离群值 Outliers
Excel 中的盒须图 翻译自https://www.excel-easy.com/examples/box-whisker-plot.html 本示例教您如何在Excel中创建盒须图.盒须图显示了数 ...
- ACCESS中查询语句:查询所得数据另存到一个指定目录下的文件夹里,并新建新的文件
select * into [excel 8.0 database=d:\aa.xls].sheet1 from bb where bb.cc="dd" excel 8.0 为什么 ...
- 第6课第4节_Binder系统_驱动情景分析_服务注册过程_分析
Service_manager.c 8074 2017/6/30 首先从应用程序分析(Android) binder_loop(bs, svcmgr_handler) { readbuf[0] = B ...
- vulnhub:easy_cloudantivirus靶机
kali:192.168.111.111 靶机:192.168.111.177 信息收集 端口扫描 nmap -A -v -sV -T5 -p- --script=http-enum 192.168. ...
- chrome 请停用以开发者
链接:https://pan.baidu.com/s/1YhWINGlUVyTE5XyBVIGW_Q 提取码:23t2 转载至 https://www.cnblogs.com/it-tsz/p/9 ...
- SSH的密钥登录配置
1.ssh的登录方法. 两种方法: (1)linux系统connect to linux ssh -l root 192.168.2.191 #直接登录. 语法:$ssh -p 22 user@hos ...