zoukankan      html  css  js  c++  java
  • ----uni-app之解决底部按钮绝对定位后被软键盘推起的bug----

    移动端h5页面经常会遇到软键盘顶起底部fixed定位元素,体验不好。记录下uni-app下同样的问题是如何解决的。

    解决思路:获取窗口尺寸,监听窗口尺寸变化,比较变化后窗口的尺寸和实际窗口尺寸的大小做相应处理。直接上代码:
    <!--html-->
    <input  type="text" @click="hideTabbar" @focus="hideTabbar" @blur="showTabbar" placeholder=""/>

    <view v-if="tabbar">底部悬浮</view>


    data(){
            return{
                tabbar: true,
                windowHeight: ''
        }
    },
    onLoad() {
        uni.getSystemInfo({
            success: (res)=> {
                this.windowHeight = res.windowHeight;
            }
        });    
        uni.onWindowResize((res) => {
            if(res.size.windowHeight < this.windowHeight){
                this.tabbar = false
            }else{
                this.tabbar = true
            }
        })
    },
    methosd:{
        showTabbar(){
            this.tabbar = true;
        },
        hideTabbar(){
            this.tabbar = false;
        }
    }

    @click和@blur 分别解决安卓和ios 兼容问题
    ---------------------------------------------------------------------------------------------------------

    ps:可以利用弹性布局,中间flex为1,底部按钮固定高度。

  • 相关阅读:
    vi编辑器
    在shell脚本中使用函数
    在shell脚本中进行条件控制以及使用循环
    shell指令expr和test指令
    利用ps指令查看某个程序的进程状态
    shell变量的使用
    创建和运行shell脚本程序
    关于强制类型转换(c语言)
    elastic 常用查询操作
    elastic 集群安装
  • 原文地址:https://www.cnblogs.com/zjy850984598/p/10638486.html
Copyright © 2011-2022 走看看