From d74d81eb6e2af914f47fe8247a5d972512f804fe Mon Sep 17 00:00:00 2001 From: "453530270@qq.com" Date: Thu, 4 Jan 2024 16:13:44 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E8=AF=95=E6=B5=8F=E8=A7=88=E5=99=A8?= =?UTF-8?q?=E8=BF=94=E5=9B=9E=E7=9A=84=E6=93=8D=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/login/components/main.vue | 20 +++++++++++++++++--- pages/login/index.vue | 15 ++------------- 2 files changed, 19 insertions(+), 16 deletions(-) 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); - } + } + }