Browse Source

监听浏览器返回

master
453530270@qq.com 2 years ago
parent
commit
a2a62fb9c2
  1. 5
      pages/login/components/main.vue
  2. 37
      pages/login/index.vue

5
pages/login/components/main.vue

@ -108,6 +108,8 @@
console.log('main created')
},
methods: {
//
@ -244,7 +246,8 @@
this.$navTo("pages/findpass/findpass")
},
}
},
}
</script>

37
pages/login/index.vue

@ -32,6 +32,14 @@
}
},
//
activated() {
if(window.history && window.history.pushState){
history.pushState(null, null, document.URL);
window.addEventListener('popstate', this.goBack, false);
}
},
/**
* 生命周期函数--监听页面加载
*/
@ -65,6 +73,27 @@
// })
},
//
goBack(){
// url
let history = store.state.urlHistory;
console.log(history,"history");
//
// if(history.length > 1) {
// // 1url
// router.push(history[history.length - 3]);
// } else {
// //
// router.push('/');
// }
// // 退popstate
// window.history.pushState('forward', null, '');
// window.history.forward(1);
// this.$router.replace({path: '/'});
},
//
onGetUserInfoSuccess({ oauth, code, userInfo }) {
//
@ -78,9 +107,13 @@
//
this.isMpWeixinAuth = false
//
this.isParty = true
// this.isParty = true
}
}
},
//
deactivated() {
window.removeEventListener('popstate', this.goBack, false);
}
}
</script>

Loading…
Cancel
Save