7***@qq.com
7***@qq.com
  • 发布:2021-01-05 17:25
  • 更新:2021-01-05 17:25
  • 阅读:589

【报Bug】popstate返回问题

分类:HTML5+

产品分类: HTML5+

HBuilderX版本号: 3.0.4

手机系统: Android

手机系统版本号: Android 10

手机厂商: 华为

手机机型: neo-al00

打包方式: 云端

示例代码:
var vm = new Vue({  
    el: '#view',  
    data: {  
        count: 10,  
        timer: null  
    },  
    mounted() {  
        var _this = this;  
        _this.pushHistory();  
var adv = plus.webview.getWebviewById('adv');  
                        adv.checkRenderedContent({  
                            interval:100  
                        }, function(){  
                            _this.timer = setInterval(() => {  
                                if (_this.count == 0) {  
                                    clearInterval(_this.timer);  
                                } else {  
                                    --_this.count; // 倒计时  
                                }  
                            }, 1000); // 每隔一秒变化一次  
                        })  

                        window.addEventListener("popstate", (e) => {  
                            _this.pushHistory();  
                            /* console.log(JSON.stringify(e))  
                            if(_this.count > 0) {  
                                _this.pushHistory();  
                                return false;  
                            } else {  
                                _this.closeView();  
                            } */  
                        }, false);   
},  
                    methods:{  
                        pushHistory() {  
                            console.log(333)  
                            var state = {  
                                title: "title",  
                                url: "#"  
                            };  
                            window.history.pushState(state, "title", "#");  
                        },

操作步骤:

点击返回不想返回,倒计时结束后可以返回。但是监听不到popstate事件

预期结果:

点击返回,会触发popstate,但是没有触发到

实际结果:
window.addEventListener("popstate", (e) => {})

监听不到事件

bug描述:

2021-01-05 17:25 负责人:无 分享
已邀请:

该问题目前已经被锁定, 无法添加新回复