diff --git a/src/page/feed/FeedList.vue b/src/page/feed/FeedList.vue index c6bee19b..6598c818 100644 --- a/src/page/feed/FeedList.vue +++ b/src/page/feed/FeedList.vue @@ -92,10 +92,16 @@ export default { } }, watch: { - feedType(val) { - feedTypesMap.includes(val) && this.$refs.loadmore.beforeRefresh(); + feedType(val, oldVal) { + feedTypesMap.includes(val) && + oldVal && + this.$refs.loadmore.beforeRefresh(); } }, + created() { + this.onRefresh(() => {}); + }, + methods: { onRefresh(callback) { api.getFeedsByType(this.feedType, 15).then(({ data }) => { diff --git a/src/routers/index.js b/src/routers/index.js index f7119a64..ae0a8ba2 100755 --- a/src/routers/index.js +++ b/src/routers/index.js @@ -17,7 +17,10 @@ const router = new VueRouter({ }; } if (savedPosition) { - return savedPosition; + // hack 滚动到保存的位置, 原生方法失效的问题 + setTimeout(() => { + window.scrollTo(savedPosition.x, savedPosition.y); + }, 100); } else { const { meta: { keepAlive = false, toTop = false } @@ -26,7 +29,9 @@ const router = new VueRouter({ from.meta.savedPosition = document.body.scrollTop || document.documentElement.scrollTop; } - return { x: 0, y: to.meta.savedPosition || 0 }; + setTimeout(() => { + window.scrollTo(0, to.meta.savedPosition); + }, 100); } } });