uniapp小程序开发设置系统状态栏高度、全屏背景图设置

效果:
在这里插入图片描述

uniapp小程序开发设置系统状态栏高度/全屏背景图设置

	<view class="login">
		<view class="status_bar">
			<!-- 这里是状态栏 -->
		</view>
		<image src="../../static/login.png" mode="" class="img"></image>

		<button open-type="getUserInfo" @getuserinfo="wxLogin" class="submit">
			<image class="wxicon" src="../../static/wx.png" mode=""></image><text>微信快速登录</text>
		</button>
		<text class="agree" @click="toAgree">查看用户协议</text>
	</view>
</template>
  • css
<style lang="less">
	page {
		height: 100%;
	}

	.login {
		position: relative;
		width: 100%;
		height: 100%;

		.status_bar {
			position: fixed;
			top: 0;
			height: var(--status-bar-height);
			width: 100%;
			background-color: #465400;
		}

		.img {
			width: 100%;
			height: 98%;
		}

  • 注意page高度需100%
  • 状态栏去掉就可实现全屏背景

系统状态栏高度官方文档

全屏背景图设置

  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
使用uniapp开发京东小程序时,可以通过设置沉浸式状态栏来提升用户体验。沉浸式状态栏是指将状态栏与应用界面融为一体,使应用的内容延伸到状态栏区域,给用户一种全屏的视觉效果。 要实现沉浸式状态栏,可以按照以下步骤进行操作: 1. 在uniapp项目的`manifest.json`文件中,找到`"mp-weixin"`或`"mp-alipay"`字段,添加`"window"`属性,并在该属性下添加`"navigationStyle"`属性,将其值设置为`"custom"`。这样可以自定义导航栏样式。 2. 在需要使用沉浸式状态栏的页面的vue文件中,可以通过设置`navigationBarStyle`属性来自定义导航栏样式。例如: ```vue <template> <view> <!-- 页面内容 --> </view> </template> <script> export default { data() { return { navigationBarStyle: { backgroundColor: '#ffffff', // 导航栏背景色 borderBottom: 'none', // 底部边框线 }, }; }, }; </script> ``` 3. 在App.vue文件中,可以通过设置`onLaunch`生命周期函数来获取系统状态栏高度,并将其保存到全局变量中。例如: ```vue <script> export default { onLaunch() { uni.getSystemInfo({ success: (res) => { uni.setStorageSync('statusBarHeight', res.statusBarHeight); }, }); }, }; </script> ``` 4. 在需要使用沉浸式状态栏的页面的vue文件中,可以通过计算属性获取系统状态栏高度,并设置页面内容的上边距。例如: ```vue <template> <view :style="marginTopStyle"> <!-- 页面内容 --> </view> </template> <script> export default { computed: { marginTopStyle() { const statusBarHeight = uni.getStorageSync('statusBarHeight'); return `margin-top: ${statusBarHeight}px;`; }, }, }; </script> ``` 这样就可以实现在uniapp开发的京东小程序中使用沉浸式状态栏了。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值