vue嵌套H5到APP,安卓键盘顶起页面内容错乱解决方案

本文主要是介绍vue嵌套H5到APP,安卓键盘顶起页面内容错乱解决方案,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

1.h5嵌套到APP,input输入框页面被键盘顶起错乱
2.解决方案:不能使用定位,使用margin-top
3.如果想满屏兼容比如登陆页面 按钮在下面 不允许出现滚动则则需要手动计算margin-top的高度
4.需求 :登陆页面内嵌H5,兼容各个类型的手机不允许出现滑动,满屏展示

<template><view class="box" :style="minHeight"><view @click="goBack"><u-icon name="close" size="32"></u-icon></view><view class="bolid-text">注册CCAPP账号</view><view class="think-text">推荐使用手机验证码登录</view><view class="phone-text">手机号</view><view class="input-sty"><u-input v-model="user.phoneNo" type="number" border="none" placeholder="请输入手机号" /></view><view class="valide-text">短信验证码</view><view class="input-sty"><view style="width: 80%;"><u-input v-model="user.verifyCode" type="number" border="none" maxlength="6" placeholder="请输入验证码" /></view><view><tui-countdown-verify :seconds="90" :successVal="successVal" @send="send" :params="1" radius="70rpx"borderColor="#05CBA3" color="#05CBA3" :resetVal="resetVal"></tui-countdown-verify></view></view><view class="shop" v-show="chanelFlag">渠道门店:{{channelName}}</view><view class="registersIos" :style="{backgroundColor: text =='注册' ? '#04CBA3' :'#696969 ',marginTop: minHeight}" @click="goSubmit">{{text}}</view><view class="xieyiIos">继续即表示您同意 <text style="color: #05CBA3;margin: 0 10rpx;text-decoration: underline;" @click="goProtocol">用户协议</text><text style="color: #05CBA3;margin: 0 10rpx;text-decoration: underline;"@click="goPrivacy">隐私条款</text></view><u-toast ref="uToast" /></view>
</template><script>// let wx1 = require("../../static/jweixin-1.6.0")import {ajax} from '@/ajax.js';import {setPageMinHeight} from '@/fn.js'import tuiCountdownVerify from "@/components/tui-countdown-verify.vue";import {loading,hideLoading,} from "@/fn.js";export default {components: {tuiCountdownVerify,},data() {return {uid: "",value: '',successVal: 0,iswx: false,resetVal: 0,channelName: '',text: '注册',user: {phoneNo: '',verifyCode: '',sharePhoneNo: '',},chanelFlag: false,system:'',minHeight:0}},mounted() {this.minHeight = uni.getSystemInfoSync().windowHeight - 350 + 'rpx' // 重要代码!!!计算出注册按钮到上个盒子的margin-top距离console.log(this.minHeight)},onLoad(e) {if (e.uid) {this.uid = e.uid}this.system = this.detectOS()console.log(this.system)if (e.sharePhoneNo) {uni.setStorageSync('sharePhoneNo', e.sharePhoneNo) //分享者的手机号码}// this.getChannel()if (uni.getStorageSync('sharePhoneNo')) {this.getChannel()this.chanelFlag = true;}let ua = window.navigator.userAgent.toLowerCase();if (ua.match(/MicroMessenger/i) == 'micromessenger') {this.iswx = true;}},onReady() {this.refCode = this.$refs.uCode;},methods: {/*用户协议*/goProtocol() {uni.navigateTo({url: '/pages/agreement/agreement'})},/*隐私政策*/goPrivacy() {uni.navigateTo({url: '/pages/agreement/clause'})},/*返回上一级别*/goBack() {uni.navigateBack(1)},/*获取渠道*/getChannel() {let that = this;ajax("get", '/health/channel/getBySharePhoneNo/' + uni.getStorageSync('sharePhoneNo')).then(res => {console.log('cc')console.log(res)console.log(res.hasOwnProperty("data"))console.log('cc')if(res.hasOwnProperty("data")){that.channelName = res.data.channelName}else{that.channelName = uni.getStorageSync('sharePhoneNo')}})},handleLaunchFn(e) {alert('success', e)},handleErrorFn(e) {alert('fail', e);},handleReadyFn(e) {alert('fail', e);},openMini() {loading()ajax('get', '/applet/nav/toApplet/' + this.uid).then(res => {hideLoading()let cData = JSON.parse(res.msg)location.href = cData.openlink});},/*发送验证码*/send() {let that = this;let reg = /^1[3456789]\d{9}$/;if (this.user.phoneNo == '') {this.resetVal++;this.$refs.uToast.show({message: '请输入手机号码',duration: 500})return false;}if (!reg.test(this.user.phoneNo)) {this.resetVal++;this.$refs.uToast.show({message: '手机号码不正确',duration: 500})return false;}// that.$u.api.getCode({// 	data: {// 		user: {// 			mobile: that.user.mobile// 		}// 	}// }).then(res => {// 	that.successVal++;// 	that.$refs.uToast.show({// 		message: '验证码已发送',// 	})// }).catch(err => {// 	that.resetVal++;// })ajax("get", "/health/user/getVerifyCode", {phoneNo: that.user.phoneNo}).then(res => {that.successVal++;that.$refs.uToast.show({message: '验证码已发送',})})},/*注册*/goSubmit() {let that = this;that.user.sharePhoneNo = uni.getStorageSync('sharePhoneNo')if (that.text == '注册') {ajax("post", "/health/user/login", that.user).then(res => {that.successVal++;that.$refs.uToast.show({message: '注册成功',})if (that.iswx) {let timer = setTimeout(() => {clearTimeout(timer)let timer = null;uni.navigateTo({url: '/pages/browser/index?sharePhoneNo='+ that.user.sharePhoneNo})}, 1000)} else {uni.navigateTo({url: '/pages/loadapp/loadapp?type=a&sharePhoneNo=' + that.user.sharePhoneNo})}}).then(res => {that.text = '注册成功'})} else {uni.navigateTo({url: '/pages/browser/index?sharePhoneNo='+ that.user.sharePhoneNo})}},/*判断页面是ios还是安卓*/detectOS() {var userAgent = navigator.userAgent || navigator.vendor || window.opera;// 检测iOS设备if (/iPad|iPhone|iPod/.test(userAgent) && !window.MSStream) {return 'iOS';}// 检测Android设备if (/Android/.test(userAgent)) {return 'Android';}// 如果不是iOS或Android,则返回其他return 'Other';},}}
</script><style scoped>.box {width: 100%;padding-top: 80rpx;padding-left: 76rpx;padding-right: 76rpx;box-sizing: border-box;height: 100vh;position: relative;/* overflow-y: scroll */}.bolid-text {font-family: PingFangSC, PingFang SC;font-weight: 800;font-size: 48rpx;color: #000000;margin-top: 74rpx;}.think-text {font-family: PingFangSC, PingFang SC;font-weight: 400;font-size: 24rpx;color: #B6B6B6;margin-top: 12rpx;}.phone-text {font-family: PingFangSC, PingFang SC;font-weight: 800;font-size: 32rpx;color: #000000;margin-top: 86rpx;}.valide-text {font-family: PingFangSC, PingFang SC;font-weight: 800;font-size: 32rpx;color: #000000;margin-top: 52rpx;}.input-sty {border-bottom: 2rpx solid #E6E6E6;display: flex;align-items: center;margin-top: 20rpx;padding-bottom: 16rpx;}.u-input {padding: 12rpx 0 !important;}.shop {box-sizing: border-box;margin-top: 62rpx;height: 96rpx;border-radius: 12rpx;border: 2rpx solid #04CBA3;font-family: PingFangSC, PingFang SC;font-weight: 600;font-size: 28rpx;color: #04CBA3;display: flex;justify-content: flex-start;align-items: center;word-break:break-all;padding-left: 20rpx;padding-right: 20rpx;box-sizing: border-box;background-color: #E5FAF5;position: absolute;top: 725rpx;left: 76rpx;}.registersAndro {width: 60%;height: 88rpx;border-radius: 12rpx;color: #FFFFFF;display: flex;justify-content: center;align-items: center;margin-top: 200rpx}.registersIos{width: 60%;height: 88rpx;border-radius: 12rpx;color: #FFFFFF;display: flex;justify-content: center;align-items: center;margin: 0 auto;/* margin-top: calc(100vh - 1000rpx); */}.xieyiAndro {font-family: PingFangSC, PingFang SC;font-weight: 400;font-size: 28rpx;color: #919191;margin: 40rpx auto 0;text-align: center;}.xieyiIos{font-family: PingFangSC, PingFang SC;font-weight: 400;font-size: 28rpx;color: #919191;text-align: center;width: 100%;margin-top: 52rpx;}
</style>

这篇关于vue嵌套H5到APP,安卓键盘顶起页面内容错乱解决方案的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/1078856

相关文章

SpringBoot全局异常拦截与自定义错误页面实现过程解读

《SpringBoot全局异常拦截与自定义错误页面实现过程解读》本文介绍了SpringBoot中全局异常拦截与自定义错误页面的实现方法,包括异常的分类、SpringBoot默认异常处理机制、全局异常拦... 目录一、引言二、Spring Boot异常处理基础2.1 异常的分类2.2 Spring Boot默

HTML5的input标签的`type`属性值详解和代码示例

《HTML5的input标签的`type`属性值详解和代码示例》HTML5的`input`标签提供了多种`type`属性值,用于创建不同类型的输入控件,满足用户输入的多样化需求,从文本输入、密码输入、... 目录一、引言二、文本类输入类型2.1 text2.2 password2.3 textarea(严格

idea粘贴空格时显示NBSP的问题及解决方案

《idea粘贴空格时显示NBSP的问题及解决方案》在IDEA中粘贴代码时出现大量空格占位符NBSP,可以通过取消勾选AdvancedSettings中的相应选项来解决... 目录1、背景介绍2、解决办法3、处理完成总结1、背景介绍python在idehttp://www.chinasem.cna粘贴代码,出

SpringBoot返回文件让前端下载的几种方式

《SpringBoot返回文件让前端下载的几种方式》文章介绍了开发中文件下载的两种常见解决方案,并详细描述了通过后端进行下载的原理和步骤,包括一次性读取到内存和分块写入响应输出流两种方法,此外,还提供... 目录01 背景02 一次性读取到内存,通过响应输出流输出到前端02 将文件流通过循环写入到响应输出流

Python结合Free Spire.PDF for Python实现PDF页面旋转

《Python结合FreeSpire.PDFforPython实现PDF页面旋转》在日常办公或文档处理中,我们经常会遇到PDF页面方向错误的问题,本文将分享如何用Python结合FreeSpir... 目录基础实现:单页PDF精准旋转完整代码代码解析进阶操作:覆盖多场景旋转需求1. 旋转指定角度(90/27

SpringBoot+Vue3整合SSE实现实时消息推送功能

《SpringBoot+Vue3整合SSE实现实时消息推送功能》在日常开发中,我们经常需要实现实时消息推送的功能,这篇文章将基于SpringBoot和Vue3来简单实现一个入门级的例子,下面小编就和大... 目录前言先大概介绍下SSE后端实现(SpringBoot)前端实现(vue3)1. 数据类型定义2.

使用Python实现在PDF中添加、导入、复制、移动与删除页面

《使用Python实现在PDF中添加、导入、复制、移动与删除页面》在日常办公和自动化任务中,我们经常需要对PDF文件进行页面级的编辑,使用Python,你可以轻松实现这些操作,而无需依赖AdobeAc... 目录1. 向 PDF 添加空白页2. 从另一个 PDF 导入页面3. 删除 PDF 中的页面4. 在

前端Visual Studio Code安装配置教程之下载、汉化、常用组件及基本操作

《前端VisualStudioCode安装配置教程之下载、汉化、常用组件及基本操作》VisualStudioCode是微软推出的一个强大的代码编辑器,功能强大,操作简单便捷,还有着良好的用户界面,... 目录一、Visual Studio Code下载二、汉化三、常用组件1、Auto Rename Tag2

Apache服务器IP自动跳转域名的问题及解决方案

《Apache服务器IP自动跳转域名的问题及解决方案》本教程将详细介绍如何通过Apache虚拟主机配置实现这一功能,并解决常见问题,本文给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,... 目录​​问题背景​​解决方案​​方法 1:修改 httpd-vhosts.conf(推荐)​​步骤

Linux(centos7)虚拟机没有IP问题及解决方案

《Linux(centos7)虚拟机没有IP问题及解决方案》文章介绍了在CentOS7中配置虚拟机网络并使用Xshell连接虚拟机的步骤,首先,检查并配置网卡ens33的ONBOOT属性为yes,然后... 目录输入查看ZFhrxIP命令:ip addr查看,没有虚拟机IP修改ens33配置文件重启网络Xh