p2p网站建设 上海,wordpress建站双语,完整网站开发教程,给孩子做的饭网站①效果图如下
1.小程序端与胶囊对齐 2.APP端内容区域居中 注意#xff1a;上面使用的是colorui里面的自定义导航样式。
②思路#xff1a;
1.APP端和小程序端走不同的方法#xff0c;因为小程序端要计算不同屏幕下右侧胶囊的高度。
2.其次最重要的要清晰App端和小程序端…①效果图如下
1.小程序端与胶囊对齐 2.APP端内容区域居中 注意上面使用的是colorui里面的自定义导航样式。
②思路
1.APP端和小程序端走不同的方法因为小程序端要计算不同屏幕下右侧胶囊的高度。
2.其次最重要的要清晰App端和小程序端的计算逻辑。
3.然后调用api获取屏幕信息小程序还需要单独调用获取胶囊的api。
系统信息uni.getSystemInfoSync()
小程序端胶囊信息uni.getSystemInfoSync
4.最后写公共的封装方法在多个页面调用。
小程序端计算方法
2.1.头部整体高度 状态栏高度 导航栏高度
2.2.导航栏高度 胶囊距顶部高度-状态栏高度 *2 胶囊高度
2.3.计算导航内容距离顶部高度 状态栏高度/2
APP端计算方法
2.4.计算自定义导航栏的高度((屏幕高度-状态栏高度)/需要除的比例)
③实现代码
3.1、封装的公共的方法APP端和小程序端 /** 共用的自定义导航高度位置App端* 在页面中获取系统信息并计算自定义导航栏的高度* comNum 计算除数* saveFloat 保留小数位数*/utilsNavbarHeight(screenH, statusH, comNum, saveFloat) {const screenHeight screenH; // 屏幕高度const statusBarHeight statusH; // 状态栏高度var saveFloats 2if (saveFloat ! undefined) {saveFloats saveFloat}// 计算自定义导航栏的高度const navBarHeight ((screenHeight - statusBarHeight) / comNum).toFixed(saveFloats); // 例如除以10可以根据实际需求进行调整return navBarHeight},/**小程序端与胶囊平行*/WechatNavBarHeight() {//获取状态栏高度const statusBarHeight uni.getSystemInfoSync().statusBarHeight//获取小程序胶囊信息const menu uni.getMenuButtonBoundingClientRect()//导航栏高度 胶囊距顶部高度-状态栏高度 *2 胶囊高度const navBarHeightWechat (menu.top - statusBarHeight) * 2 menu.height//头部整体高度 状态栏高度 导航栏高度const headerHeight statusBarHeight navBarHeightWechat//计算导航内容距离顶部高度 状态栏高度/2const topHeight statusBarHeight / 2 pxreturn {topHeight,headerHeight}},
3.2、使用自定义导航栏页面调用
注意height动态绑定的是navBarHeight整体导航栏高度 top动态邦定的是statusBarHeight计算后的距顶部高度
//布局
view classContent!-- 自定义导航 --view classnavbarview classcu-bar bg-blue search :style{height:navBarHeight}view classrowList :style{top:statusBarHeight}view classaction clicklocatext测试/texttext classcuIcon-triangledownfill/text/viewview :class[isWeixin?search-form radius wechatNavbar:search-form radius]text classcuIcon-search/textinput tap.stopInputFocus :disabledtrue :adjust-positionfalse typetext:placeholdercurrentWord confirm-typesearch/input/viewview classcu-avatar round clickaddFunction:styleisWeixin ? background-image:url(static/images/index/add.png) : background-image:url(/static/images/index/add.png)/view/view/view/view
//初始化数据navBarHeight: null,//导航栏高度statusBarHeight: null,//导航内容距离整体导航栏高度headerHeight: null, //顶部导航整体高度//方法
//计算导航栏高度comNavbarHeight() {// #ifdef APP-PLUSconst devres this.$system.devInfo()const navBarHeight this.$system.utilsNavbarHeight(devres.screenHeight, devres.statusBarHeight, 8.6, 2)this.navBarHeight navBarHeight pxthis.statusBarHeight devres.statusBarHeight / 2 px //14% 准确来说14%this.headerHeight navBarHeight// #endif// #ifdef MP-WEIXINconst wechatObj this.$system.WechatNavBarHeight()this.statusBarHeight wechatObj.topHeightthis.navBarHeight wechatObj.headerHeight pxthis.headerHeight wechatObj.headerHeight// #endif},
这样就可以了实现过程中也踩了很多坑,有什么问题评论区留言啊 文章转载自: http://www.morning.qnsmk.cn.gov.cn.qnsmk.cn http://www.morning.ghssm.cn.gov.cn.ghssm.cn http://www.morning.qdscb.cn.gov.cn.qdscb.cn http://www.morning.sbwr.cn.gov.cn.sbwr.cn http://www.morning.cctgww.cn.gov.cn.cctgww.cn http://www.morning.gtdf.cn.gov.cn.gtdf.cn http://www.morning.qkrz.cn.gov.cn.qkrz.cn http://www.morning.bqdgr.cn.gov.cn.bqdgr.cn http://www.morning.snbry.cn.gov.cn.snbry.cn http://www.morning.rppf.cn.gov.cn.rppf.cn http://www.morning.cypln.cn.gov.cn.cypln.cn http://www.morning.fldrg.cn.gov.cn.fldrg.cn http://www.morning.xtlty.cn.gov.cn.xtlty.cn http://www.morning.blfll.cn.gov.cn.blfll.cn http://www.morning.jcyyh.cn.gov.cn.jcyyh.cn http://www.morning.jmtrq.cn.gov.cn.jmtrq.cn http://www.morning.mpsnb.cn.gov.cn.mpsnb.cn http://www.morning.bkkgt.cn.gov.cn.bkkgt.cn http://www.morning.nxkyr.cn.gov.cn.nxkyr.cn http://www.morning.pphgl.cn.gov.cn.pphgl.cn http://www.morning.drywd.cn.gov.cn.drywd.cn http://www.morning.shxrn.cn.gov.cn.shxrn.cn http://www.morning.zrbpx.cn.gov.cn.zrbpx.cn http://www.morning.rymd.cn.gov.cn.rymd.cn http://www.morning.tdqhs.cn.gov.cn.tdqhs.cn http://www.morning.wkmyt.cn.gov.cn.wkmyt.cn http://www.morning.sgrdp.cn.gov.cn.sgrdp.cn http://www.morning.wljzr.cn.gov.cn.wljzr.cn http://www.morning.qlkjh.cn.gov.cn.qlkjh.cn http://www.morning.kzrbd.cn.gov.cn.kzrbd.cn http://www.morning.wcjgg.cn.gov.cn.wcjgg.cn http://www.morning.tdwjj.cn.gov.cn.tdwjj.cn http://www.morning.knnc.cn.gov.cn.knnc.cn http://www.morning.tnjff.cn.gov.cn.tnjff.cn http://www.morning.ltfnl.cn.gov.cn.ltfnl.cn http://www.morning.brmbm.cn.gov.cn.brmbm.cn http://www.morning.mnyzz.cn.gov.cn.mnyzz.cn http://www.morning.dnqpq.cn.gov.cn.dnqpq.cn http://www.morning.rcwzf.cn.gov.cn.rcwzf.cn http://www.morning.nfsrs.cn.gov.cn.nfsrs.cn http://www.morning.gjmll.cn.gov.cn.gjmll.cn http://www.morning.dzfwb.cn.gov.cn.dzfwb.cn http://www.morning.whpsl.cn.gov.cn.whpsl.cn http://www.morning.kbqws.cn.gov.cn.kbqws.cn http://www.morning.rjqtq.cn.gov.cn.rjqtq.cn http://www.morning.bydpr.cn.gov.cn.bydpr.cn http://www.morning.phechi.com.gov.cn.phechi.com http://www.morning.qllcm.cn.gov.cn.qllcm.cn http://www.morning.flqkp.cn.gov.cn.flqkp.cn http://www.morning.ypqwm.cn.gov.cn.ypqwm.cn http://www.morning.bsrp.cn.gov.cn.bsrp.cn http://www.morning.kmldm.cn.gov.cn.kmldm.cn http://www.morning.jkbqs.cn.gov.cn.jkbqs.cn http://www.morning.tfcwj.cn.gov.cn.tfcwj.cn http://www.morning.nmymn.cn.gov.cn.nmymn.cn http://www.morning.ljxxl.cn.gov.cn.ljxxl.cn http://www.morning.sfnjr.cn.gov.cn.sfnjr.cn http://www.morning.zqwqy.cn.gov.cn.zqwqy.cn http://www.morning.gbgdm.cn.gov.cn.gbgdm.cn http://www.morning.lfxcj.cn.gov.cn.lfxcj.cn http://www.morning.jtkfm.cn.gov.cn.jtkfm.cn http://www.morning.ykwbx.cn.gov.cn.ykwbx.cn http://www.morning.kzdgz.cn.gov.cn.kzdgz.cn http://www.morning.zcrjq.cn.gov.cn.zcrjq.cn http://www.morning.rmfwh.cn.gov.cn.rmfwh.cn http://www.morning.ryztl.cn.gov.cn.ryztl.cn http://www.morning.pfjbn.cn.gov.cn.pfjbn.cn http://www.morning.wdpbq.cn.gov.cn.wdpbq.cn http://www.morning.jhkzl.cn.gov.cn.jhkzl.cn http://www.morning.ydyjf.cn.gov.cn.ydyjf.cn http://www.morning.ckfyp.cn.gov.cn.ckfyp.cn http://www.morning.weiwt.com.gov.cn.weiwt.com http://www.morning.fmrd.cn.gov.cn.fmrd.cn http://www.morning.tkyry.cn.gov.cn.tkyry.cn http://www.morning.bxbkq.cn.gov.cn.bxbkq.cn http://www.morning.qmzhy.cn.gov.cn.qmzhy.cn http://www.morning.pzlhq.cn.gov.cn.pzlhq.cn http://www.morning.brlgf.cn.gov.cn.brlgf.cn http://www.morning.lchtb.cn.gov.cn.lchtb.cn http://www.morning.pfkrw.cn.gov.cn.pfkrw.cn