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;
                },
    }
  • 相关阅读:
    hadoop wordcount
    hadoop map reduce 实例wordcount的使用
    玉髓
    数据类型检测的四种方式
    天猫前端招聘要求
    正则示例1
    字面量和实例创建的区别
    正则表达式
    面试题1
    this关键字
  • 原文地址:https://www.cnblogs.com/liufeiran/p/15428827.html
Copyright © 2011-2022 走看看