Description
Version
3.0.1
Reproduction link
http://jsfiddle.net/L7hscd8h/3877/
Steps to reproduce
- Open provided jsfiddle.net link;
- Open browser console;
- Click on 'first a' ;
- Click on 'first b' ;
- Click on 'second a' ;
- Click on 'first a' again;
- Inspect console output.
What is expected?
Component props should be set to ones defined in route in beforeRouteEnter
hook even when transitions are used.
Expected output:
vue-component-3: mounted
vm.title: first_a
vm.title: first_b
vue-component-4: mounted
vm.title: second_a
vm.title: first_a
vue-component-3: mounted
What is actually happening?
It seems that props are set after the transition is finished, as well as the mounted
hook is called. The connection between those two is easily determined by looking at the order of console output with or without transition tag (like at this slightly modified JSFiddle: http://jsfiddle.net/L7hscd8h/3878/).
Actual output:
vue-component-3: mounted
vm.title: first_a
vm.title: first_b
vue-component-4: mounted
vm.title: second_a
vm.title: first_b <--- the problem
vue-component-3: mounted
I presume this issue has something to do with Vue reusing components (which had only been a pain in the head for me), since it doesn't occur when switching routes with the same component.
It is undeniably vital for correct values of props to be available in beforeRouteEnter
since they can be used to fetch data asynchronously for components. Or, if you like, not fetching, but sending.
Used versions:
vue-router 3.0.1 (sha512-vLLoY452L JBpALMP5UHum9 7nzR9PeIBCghU9ZtJ1eWm6ieUI8Zb/DI3MYxH32bxkjzYV1LRjNv4qr8d uX/w==)
vue 2.5.13 (sha512-3D lY7HTkKbtswDM4BBHgqyq qo8IAEE8lz8va1dz3LLmttjgo0FxairO4r1iN2OBqk8o1FyL4hvzzTFEdQSEw==)