Commit cfda44a2 authored by 袁玲利's avatar 袁玲利

游戏排行榜

parent a857c75a
...@@ -114,6 +114,19 @@ export default { ...@@ -114,6 +114,19 @@ export default {
}; };
}, },
mounted() { mounted() {
const that = this;
// 监听返回
this.pushHistory();
window.addEventListener(
"popstate",
function (e) {
// 为了避免只调用一次
that.pushHistory("title1");
// 自定义方法, 直接关闭网页或返回小程序上一页
that.goBack();
},
false
);
this.games.sort(() => 0.5 - Math.random()); this.games.sort(() => 0.5 - Math.random());
this.params.userid = this.getQueryParams("userId"); this.params.userid = this.getQueryParams("userId");
this.params.sessionid = this.getQueryParams("sessionid"); this.params.sessionid = this.getQueryParams("sessionid");
...@@ -123,6 +136,17 @@ export default { ...@@ -123,6 +136,17 @@ export default {
this.init(); this.init();
}, },
methods: { methods: {
// 添加一条 history 实体作为替代原来的 history 实体
pushHistory(str = "title", url = "#") {
const state = {
title: str,
url,
};
window.history.pushState(state, state.title, state.url);
},
goBack() {
console.log('游戏排行榜的物理返回按钮')
},
init() { init() {
const self = this; const self = this;
this.timer = setInterval(() => { this.timer = setInterval(() => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment