微信内置浏览器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)
                });
            }
        },

 

上一篇:[渝粤教育] 广东-国家-开放大学 21秋期末考试建筑工程概预算10326k2


下一篇:drf中仿照SimpleRateThrottle自定制频率类