diff --git a/pages/login/components/main.vue b/pages/login/components/main.vue index 65d17a5..4cb3944 100644 --- a/pages/login/components/main.vue +++ b/pages/login/components/main.vue @@ -108,10 +108,19 @@ console.log('main created') }, - - + mounted() { + // 监听返回事件,点击系统返回时 + if(window.history && window.history.pushState){ + window.addEventListener('popstate',this.goback,false) + } + }, methods: { - + + goback(){ + console.log("6666666666666666666") + let path = this.$route.path + this.$toast(path) + }, // 账户类型 radioChange(evt) { this.userType = evt.detail.value @@ -247,6 +256,11 @@ }, }, + //退出页面 + destroyed(){ + //销毁监听 + window.removeEventListener('popstate',this.goback,false) + } } diff --git a/pages/login/index.vue b/pages/login/index.vue index f700270..eec4a9c 100644 --- a/pages/login/index.vue +++ b/pages/login/index.vue @@ -32,14 +32,6 @@ } }, - // - activated() { - if(window.history && window.history.pushState){ - history.pushState(null, null, document.URL); - window.addEventListener('popstate', this.goBack, false); - } - }, - /** * 生命周期函数--监听页面加载 */ @@ -109,11 +101,8 @@ // 已获取到了第三方用户信息 // this.isParty = true } - }, - // 离开页面销毁 - deactivated() { - window.removeEventListener('popstate', this.goBack, false); - } + } + }