zoukankan      html  css  js  c++  java
  • vue+hbuilder监听安卓返回键问题

    1.监听安卓返回键问题

    效果:在一级页面按一下返回键提示退出应用,按两下退出应用;在其它页面中,按一下返回上个历史页面

    1
    2
    import mui from './assets/js/mui.min.js'
    Vue.prototype.$mui = mui;

    在一级页面mounted时

    复制代码
     1 this.$mui.plusReady( () =>{
     2 var backcount = 0;
     3 this.$mui.back = ()=> {
     4 if (this.$mui.os.ios) return;
     5 if (backcount > 0) {
     6 if (window.plus) plus.runtime.quit();
     7 return;
     8 };
     9 this.$layer.msg('再点击一次退出应用!')
    10 backcount++;
    11 setTimeout( () =>{
    12 backcount = 0;
    13 }, 2000);
    14 };
    15 })
    复制代码

     在其它页面mounted时

    1 this.$mui.plusReady(() => {
    2 this.$mui.back = () => {
    3 this.$router.go(-1);
    4 };
    5 });

    在每次组件加载时都重写一下返回按钮的事件,如果不重写,此页面就会使用上个页面中定义的返回事件,这个事件可能是退出app也可能是返回上次历史页面,这样就会造成事件冲突,所以在每次组件加载时都重写返回事件.

    2.键盘弹起会把固定在底部的导航顶上去

    复制代码
    data() {
        return {
          docmHeight: document.documentElement.clientHeight, //默认屏幕高度
          showHeight: document.documentElement.clientHeight, //实时屏幕高度
          hidshow: true //显示或者隐藏footer
        };
      },
      mounted() {
        // window.onresize监听页面高度的变化
        window.onresize = () => {
          return (() => {
            this.showHeight = document.body.clientHeight;
          })();
        };
      },
      watch: {
        showHeight: function() {
          if (this.docmHeight > this.showHeight) {
            this.hidshow = false;
          } else {
            this.hidshow = true;
          }
        }
      }
    复制代码

    注意document要撑满屏幕高度!

    参考地址:https://www.jianshu.com/p/210fbc846544

    3.切换页面的转场效果使用:vueg

    参考网址:https://github.com/jaweii/vueg

    4.上拉加载下拉刷新使用:mescroll

    参考网址:http://www.mescroll.com/

    5.设置沉浸式

    复制代码
    配置manifest.json
    "plus": {
        "statusbar": {
            "immersed": true 
        },
    
    
        "google": {
            "immersedStatusbar": true,
        }
    }
    复制代码

    获取状态栏高度,可以使用mui提供的方法,也可以使用js  :  window.screen.height - window.innerHeight,

    然后把这个高度给顶部导航和某些页面加上上边距就行了

  • 相关阅读:
    杭州电子科技大学程序设计竞赛(2016’12)- 网络同步赛 1001
    AtCoder Beginner Contest 050 ABC题
    2016年第四届湘潭大学新生趣味程序设计竞赛
    华东交通大学2016年ACM“双基”程序设计竞赛 1008
    移动端报表JS开发示例
    unity shader入门
    现代控制理论思考题----倒立摆小车控制算法研究
    Linux驱动基础:msm平台,modem等framework加载
    简谈高通Trustzone的实现
    现代控制理论课件分享及课后思考题(初稿待完善)
  • 原文地址:https://www.cnblogs.com/wordblog/p/10205798.html
Copyright © 2011-2022 走看看