uni开发APP问题解决方案(持续更新)

iOS下拉刷新时顶部漂移

在页面methods同级加上如下代码,

<template>
	<view>
		<view class="navbar" :style="{position:headerPosition,top:headerTop}">
			...代码略
		</view>
	</view>
</template>
<script>
	data() {
    
    
		return {
    
    
			headerPosition:"fixed",
			headerTop:"0px",
		}
	},
	onLoad(options){
    
    
		// #ifdef H5
		this.headerTop = document.getElementsByTagName('uni-page-head')[0].offsetHeight+'px';
		// #endif
	},
	onPageScroll(e){
    
    
		if(e.scrollTop>=0){
    
    
			this.headerPosition = "fixed";
		}else{
    
    
			this.headerPosition = "absolute";
		}
	}
</script>

iOS登录时键盘顶部闪烁

在原有的输入框同级增加一个输入框

<template>
	<view>
		<view class="input">
			<input type="number" v-model="from.account" placeholder="请输入手机号" :maxlength="11">
			<input type="number" style="height: 0;min-height: 0;overflow: hidden;">
		</view>
	</view>
</template>

如果想去除IOS软键盘上方横条,在pages.json中某个页面或者全局配置 style,关键代码:softinputNavBar:none

// 某个页面去除方案
"pages": [
	{
    
    
		"path": "pages/index/index",
		"style": {
    
    
			"app-plus": {
    
    
				"softinputNavBar": "none"
			}	
		}
	}
],
// 全局去除方案
"globalStyle": {
    
    
	"app-plus": {
    
    
		"softinputNavBar": "none"
	}	
}

iOS底部手势提示线适配

在页面需要适配的地方增加css,例如:

page{
    
    
	padding-bottom: constant(safe-area-inset-bottom);
	padding-bottom: env(safe-area-inset-bottom); 
}

猜你喜欢

转载自blog.csdn.net/qq_38188228/article/details/129879560