vue3 ios环境下移动端表头不固定问题

vue3移动端表头不固定问题


移动端底部按钮 不随着软键盘滚动代码如下:

//表头位置固定但 会 弹跳可下载 插件 固定
import inobounce from "inobounce";
  let u = navigator.userAgent;
    if (u.indexOf("iPhone") > -1) {
      inobounce.enable();
    }
//表头位置固定设置
  function handleScroll(event) {
      let header = document.getElementsByClassName("header")[0];
      // console.log("header1:", header);
      var scrollTop =
        document.documentElement.scrollTop || document.body.scrollTop;
      if (list.datalist.length == 0) {
        let chatContent = document.getElementsByClassName("chatContent")[0];
        chatContent.style.overflow = "hidden !important;";
        chatContent.style.height =
          window.document.clientHeight + "px !important";
        header.style.top = scrollTop + "px";
      } else {
        header.style.top = scrollTop + "px";
      }
    }
    //键盘收起弹出代码
 function getKeyboardState() {
      list.monitorKeyboard = new MonitorKeyboard();
      list.monitorKeyboard.onStart();

      // 监听虚拟键盘弹出事件
      list.monitorKeyboard.onShow(() => {
        // console.log("键盘弹出");
        // console.log("3333");
      });

      //监听键盘收起的事件
      list.monitorKeyboard.onHidden(() => {
        // console.log("键盘收起");
        // if (list.inpValue != "") {
        //   btnSend();
        // }
      });
    }
    function handleKeyboardShow() {
    
      if (window.innerHeight > document.documentElement.clientHeight) {
        // 禁用滚动
        document.body.style.overflow = "hidden";
      } else {
        // 恢复滚动
        document.body.style.overflow = "";
      }
    }
  onMounted(() => {
      getKeyboardState();
      // 添加键盘弹出事件的监听
      window.addEventListener("keyboardWillShow", keyboardWillShowHandler);
      // 监听键盘弹出事件
      window.addEventListener("resize", handleKeyboardShow);
      // // 初始化时检查一次;
      // nextTick(checkKeyboard);
      // 使header 表头位置固定
      window.addEventListener("scroll", handleScroll);
      // }
      var u = navigator.userAgent;
      let isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
      if (isiOS) {
        list.isShow = true;
      }
    });
  • 3
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值