国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

uniapp 內(nèi)嵌 webview 客服網(wǎng)頁,呼出鍵盤遮擋輸入框問題解決記錄

這篇具有很好參考價值的文章主要介紹了uniapp 內(nèi)嵌 webview 客服網(wǎng)頁,呼出鍵盤遮擋輸入框問題解決記錄。希望對大家有所幫助。如果存在錯誤或未考慮完全的地方,請大家不吝賜教,您也可以點擊"舉報違法"按鈕提交疑問。

有很多情況需要在app端內(nèi)嵌一個H5客服網(wǎng)頁,但這個頁面一般都是有打字的需求,但由于大部分情況下網(wǎng)頁都是默認(rèn)鋪滿整個畫面,導(dǎo)致鍵盤彈出時出現(xiàn)遮擋輸入框的問題。

直接上代碼:文章來源地址http://www.zghlxwxcb.cn/news/detail-740143.html

<template>
	<view class="service-container">
		<view class="content">
			// 這里正常引入webview
			<web-view :src="url">
			</web-view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				url: '',  // 網(wǎng)址
				height: 0, // 頁面高度
				barHeight: 0, // 狀態(tài)欄高度
				kbHeight: 0 // 鍵盤高度
			};
		},
		onLoad() {
			
			this.url = ‘xxxxxxx’;
			// 這里是為了用原生的導(dǎo)航欄遮擋H5客服頁面的頭部,因為大部分客服頁面都沒有返回鍵
				setTimeout(() => {
					uni.setNavigationBarTitle({
						title: '在線客服'
					})
				}, 1000)
				console.log(this.url);
		},
		onShow() {
			//  監(jiān)聽鍵盤高度變化
			uni.onKeyboardHeightChange((obj) => {
				// 獲取系統(tǒng)信息
				let _sysInfo = uni.getSystemInfoSync();
				let _heightDiff = _sysInfo.screenHeight - _sysInfo.windowHeight
				let _diff = obj.height - _heightDiff
				// 鍵盤高度
				this.kbHeight = (_diff > 0 ? _diff : 0) - 2;
			})
		// 同時監(jiān)聽頁面變化
			uni.onWindowResize(res => {
				console.log(res);
				if (res.size.windowHeight < this.height) {
					setTimeout(() => {
						this.wv.setStyle({
							top: this.barHeight,
							// webview的高度動態(tài)修改為減去鍵盤高度后的
							height: this.height - this.kbHeight,
							bottom: 0
						})
					}, 100)
				} else {
					setTimeout(() => {
						this.wv.setStyle({
							top: this.barHeight,
							// 這里可以根據(jù)自己情況微調(diào)
							height: this.height + 60,
							bottom: 0
						})
					}, 100)
				}
			})
		},
		onReady() {
			// 首次進(jìn)入頁面時,webview高度 = 整個頁面高度
			let currentWebview = this.$scope.$getAppWebview();
			uni.getSystemInfo({
				success: res => {
					this.height = res.windowHeight;
					setTimeout(() => {
						this.wv = currentWebview.children()[0];
						this.wv.setStyle({
							top: this.barHeight,
							height: this.height + 60,
							bottom: 0
						});
					}, 100);
				}
			});
		}
	};
</script>

<style lang="scss">
	.service-container {
		background-color: #f2f5ff;
	}
</style>

到了這里,關(guān)于uniapp 內(nèi)嵌 webview 客服網(wǎng)頁,呼出鍵盤遮擋輸入框問題解決記錄的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實不符,請點擊違法舉報進(jìn)行投訴反饋,一經(jīng)查實,立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費用

相關(guān)文章

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包