uniapp中弹起软键盘的相关设置,ios中软键盘弹起不兼容的混合写法

1.首先需要在page.json中设置软键盘弹起的相关属性

{"path": "your page link",
	"style": {
		"app-plus": {
			"softinputMode": "adjustResize", // 自适应软键盘弹起页面高度
			"softinputNavBar": "none" // 取消ios中软键盘上方完成按钮等
		}
	}
}

2.页面中动态设置需要滚动的元素高度

// 键盘获取焦点事件:
inputFocus(e) {
	let systemInfo = uni.getSystemInfoSync(); 
	let screentHeight = systemInfo.screenHeight;// 获取屏幕高度
	let statusBarHeight = systemInfo.statusBarHeight; // 获取状态栏高度
	let bottombarHeight = 0; //底部输入框高度
	const query = uni.createSelectorQuery().in(this);
	query.select('.bottom').boundingClientRect(data => {
		bottombarHeight = data.height; // 动态获取底部输入框相关结构的高度
		this.height = screentHeight - statusBarHeight - bottombarHeight - e.detail.height - 44 + 'px'; // e.detail.height为软键盘高度
		this.jumpToMaoPoint(false); // 滚动区域滚动至最底端
	}).exec();
},

 

评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值