uniapp-微信小程序开发 随记 --自定义顶部栏的样式处理

本文档介绍了在UI设计图与实际小程序页面样式不匹配时,如何通过自定义导航栏来解决这一问题。具体步骤包括在pages.json中设置全局样式为custom,引用colorUI的cu-custom组件,并在App.vue中处理不同平台的适配。通过这种方法,可以消除小程序自带导航栏并实现与设计图一致的渐变效果。
摘要由CSDN通过智能技术生成

问题起因 --由于UI设计图导航栏和内容相连 是渐变色以及 编写页面的过程中发现导航栏不能与页面完美契合 中间有一条线 导致页面样式不一致

1.解决方案:自定义导航栏
2.解决步骤:1>在配置项pages.json 文件中 globalStyle中添加"navigationStyle": “custom”,

“globalStyle”: {
“navigationStyle”: “custom”,
},
该设置会取消掉小程序中自带的导航栏
3.参考colorui 文档 中cu-custom组件
4.组件的使用 1.首先 将cu-cusetom 的包移入 项目文件中 在App.vue 中 引入colorUI的编写的方法
onLaunch: function() {
uni.getSystemInfo({
success: function(e) {
// #ifndef MP
Vue.prototype.StatusBar = e.statusBarHeight;
if (e.platform == ‘android’) {
Vue.prototype.CustomBar = e.statusBarHeight + 50;
} else {
Vue.prototype.CustomBar = e.statusBarHeight + 45;
};
// #endif

				// #ifdef MP-WEIXIN
				Vue.prototype.StatusBar = e.statusBarHeight;
				let custom = wx.getMenuButtonBoundingClientRect();
				Vue.prototype.Custom = custom;
				Vue.prototype.CustomBar = custom.bottom + custom.top - e.statusBarHeight;
				// #endif		

				// #ifdef MP-ALIPAY
				Vue.prototype.StatusBar = e.statusBarHeight;
				Vue.prototype.CustomBar = e.statusBarHeight + e.titleBarHeight;
				// #endif
			}
		})

		]}
5. 有可能小程序开发工具会报错  具体问题具体处理
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值