- 在你跳转前的页面里添加跳转到详情页的路由
@click="$router.push('/details')"
2.在你的router文件夹下里的index跳转前的路由里设置
{
path: '/teacher',
name: 'teacher',
component: () => import(/* webpackChunkName: "about" */ '../views/teacher.vue'),
meta: {
keepAlive: true //需要缓存
}
},
这里能够解决两个页面一起滚动的问题
const router = new VueRouter({
mode: 'history',
base: process.env.BASE_URL,
routes,
scrollBehavior (to, from, savedPosition) {
if (savedPosition) {
return savedPosition
} else {
return { x: 0, y: 0 }
}
},
})
3.跳转的详情页里设置跳转回来页面的路由,注意这里用back
<img src="../assets/mask_01.png" alt="" class="leftarrow" @click="$router.back(-1)" />