uniapp获取导航胶囊信息

文章描述:

uniapp小程序获取导航胶囊信息,来实现各个设备导航胶囊距离的控制。

<template>
	<view>
		<view class="top_view" :style="'margin-top:'+ (titletop)+'px;'" >
		 返回
		</view>
	</view>
</template>
export default{
	data(){
		return{
			titleheight: 0,
			titletop:0,
		}
	},
	onShow() {
		
		this.getHeight();
	},
	methods:{
		getHeight() {
				let res = uni.getMenuButtonBoundingClientRect();
				this.titletop = res.top;
				this.titleheight = res.height
				console.log(res);
				console.log("titletop的值", this.titletop);
				console.log("titleheight的值", this.titleheight);
				console.log("一半的titleheight的值", this.titleheight/2);
		}
	}
}

 

{
	"path": "pages/index/index",
	"style": {
		"navigationBarTitleText": "uni-app",
		"navigationStyle": "custom"
	}
}

 

发布时间:2022/12/14

发表评论