Vue-router: scrollBehavior ( to, from, savedPosition ) console.log(to) == console.log(from) ; //true

Created on 27 Feb 2017  ·  5Comments  ·  Source: vuejs/vue-router

Vue.js / vue-router versions

2.2.0

Reproduction Link

https://jsfiddle.net/wjunjie/fg0eu4ey/

Steps to reproduce

Click link:
scrollBehavior ( to, from, savedPosition ) { console.log(to) == console.log(from) ; //true }

What is Expected?

to: Route: the target Route Object being navigated to.

from: Route: the current route being navigated away from.

What is actually happening?

to: Route: the target Route Object being navigated to.

from: Route: the target Route Object being navigated to.

// 英文不好,希望回复中文,谢谢。

2.x bug

Most helpful comment

But to is always equal to from :joy: :joy: :joy: https://jsfiddle.net/dus1anxL/...
Creating a PR to fix this..

All 5 comments

I'd say this is intended to make it possible to recognise the same router view is being reused. It also happen with params btw.
wdyt @fnlctrl

But to is always equal to from :joy: :joy: :joy: https://jsfiddle.net/dus1anxL/...
Creating a PR to fix this..

Hi, is there any workaround until next release?

Yes, that's a good question. I was bitten by this yesterday. I'm not sure if there is a reasonable workaround.

Just released 2.3.1 for this fix.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

achen224 picture achen224  ·  3Comments

druppy picture druppy  ·  3Comments

gil0mendes picture gil0mendes  ·  3Comments

rr326 picture rr326  ·  3Comments

thomas-alrek picture thomas-alrek  ·  3Comments