uni-app 微信小程序导航栏navigationBar 安卓不居中问题

1.直接去掉导航栏 在界面里自定义导航栏

在pages.json中style添加

"globalStyle": {
		"navigationBarTextStyle": "white",
		"navigationBarTitleText": "首页",
		"navigationBarBackgroundColor": "#000000",
		"backgroundColor": "#303133",
		// "app-plus": {
		// 	"background": "#303133"
		// },
		"navigationStyle":"custom",
			"app-plus":{
				"titleView":false
			}

	}

2.创建自定义标题组件

在components文件夹里创建自定义组件

<template>
    <view class="header" >
        <view class="flexbox" :style="[{'height': customBarH + 'px', 'padding-top': statusBarH + 'px', 'color': titleColor, 'background': bgColor}]">
        <!--    <view @tap="goBack">
                <slot name="back">返回</slot>
            </view> -->
			<view style="width: 36px;"></view>
            <view>{{title}}</view>
            <view style="width: 36px;"></view>
        </view>
    </view>
</template>
 
<script>
    export default {
        data() {
            return {
                statusBarH: 0,
                customBarH: 0
            }
        },
        props: {
            title: { type: String, default: '' },
            titleColor: { type: String, default: '#ffffff' },
            bgColor: { type: String, default: '#000000' },
        },
      
        methods: {
            goBack() {
                uni.navigateBack()
            }
        },
		created() {
			let self = this;
			uni.getSystemInfo({
			    success:function(e){
			        self.statusBarH = e.statusBarHeight + 10
			        let custom = wx.getMenuButtonBoundingClientRect()
			        self.customBarH = custom.height + 10
			    }
			})
		}
    }
</script>
 
<style>
	.header{
		width: 100vw;
	}
	.flexbox{
		display: flex;
		justify-content: space-between;
		padding: 0 20px;
	}
</style>

3.使用自定义组件

<header-bar :title=titleName >
     <!-- <text slot="back">返回</text> -->
</header-bar>
<script>
	export default {
		data() {
			return {
			titleName="标题"
			}
		}
}
</script>

  • 4
    点赞
  • 25
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
uni-app实现微信小程序的一键登录功能,需要使用button组件的open-type开放能力。在button标签设置open-type为"getUserInfo",并通过@getuserinfo事件来触发wxLogin方法。具体代码如下: <button type="default" open-type="getUserInfo" @getuserinfo="wxLogin">一键登录微信小程序</button> 在App.vue文件,可以配置小程序的全局样式、生命周期函数等。manifest.json文件用于配置应用名称、appid、logo、版本等打包信息。pages.json文件用于配置页面路径、页面窗口样式、tabBar、navigationBar等页面类信息。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *3* [uni-app实现微信小程序一键登录](https://blog.csdn.net/qq_45797421/article/details/118339987)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] - *2* [uni-app实现购物商城的微信小程序,优秀毕业设计源代码,小白必看!](https://download.csdn.net/download/qq_42257666/87667930)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Y_Hungry

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值