diff --git a/src/router/index.js b/src/router/index.js index 8532da6..03be72d 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -241,7 +241,14 @@ const routes = [ ] const router = new VueRouter({ - scrollBehavior: () => ({ y: 0 }), + // 记录上个页面的滚动位置 + scrollBehavior(to, from, savedPosition) { + if (savedPosition) { + return savedPosition + } else { + return { x: 0, y: 0 } + } + }, routes }) diff --git a/src/views/home/modules/GoodsVantCard.vue b/src/views/home/modules/GoodsVantCard.vue index 8a7cab8..f5d8265 100644 --- a/src/views/home/modules/GoodsVantCard.vue +++ b/src/views/home/modules/GoodsVantCard.vue @@ -68,6 +68,11 @@ export default { methods: { onReachBottom() { this.$emit('onReachBottom') + }, + itemClick(goodsId) { + this.$router.push({ + path: `/detail/${goodsId}` + }) } } }