vue-router的scrollBehavior,好像不起作用。求解。谢谢了
粉丝福利 : 关注VUE中文社区公众号,回复视频领取粉丝福利
scrollBehavior (to, from, savedPosition) {
if (savedPosition) {
return savedPosition
} else {
return { x: 0, y: 0 }
}
在路由里这样写的,但是不起作用,打印savedPosition的值是有的,不知道为什么
-------------------------以上实在linux上的滚动行为没反应-----------------------------
```export default new Router({
mode: 'history',
scrollBehavior (to, from, savedPosition) {
if (savedPosition) {
console.log(savedPosition)
return savedPosition
} else {
return { x: 0, y: 0 }
}
},
routes: [
{
path: '/',
component: List
},
{
path:'/topic/:id',
component:Detail
}
]
})```
上面是在win10上的写法,一样的