zoukankan      html  css  js  c++  java
  • 微信内置浏览器h5监听手机返回键

    vant:

    mounted(){
            //手机后退键
            let self = this;
            if (window.history && window.history.pushState) {
                $(window).on('popstate', function () {
                    self.goback();
                });
                history.pushState(null, null, location.href);
                window.addEventListener('popstate', function (event) {
                    history.pushState(null, null, location.href);
                });
            }
        },

    uniapp:

    mounted() {
                var a = document.getElementsByClassName('uni-page-head-hd')[0];
                a.style.display = 'none';
                //手机后退键
                let self = this;
                if (window.history && window.history.pushState) {
                    window.addEventListener('popstate', function (event) {
                        uni.redirectTo({
                            url:self.$pageUrl.trainDetails + `?PlanID=${self.PlanID}`
                        },300)
                    });
                }
            },

     或者:

    methods:{
                onBackPress(e){
                  // console.log("监听返回按钮事件",e);
                  uni.redirectTo({
                      url:self.$pageUrl.trainDetails + `?PlanID=${self.PlanID}`
                  },300)
                  // 此处一定姚要return为true,否则页面不会返回到指定路径
                  return true;
                },
    }
  • 相关阅读:
    类与类之间的关系图
    UML介绍
    数据建模
    状态图
    部署图
    用例图
    业务建模
    时序图
    postgresql 维护手册
    ashx文件的使用(转)
  • 原文地址:https://www.cnblogs.com/liufeiran/p/15428827.html
Copyright © 2011-2022 走看看