vuejs / v2.vuejs.org

📄 Documentation for Vue 2
https://v2.vuejs.org
MIT License
5.03k stars 3.42k forks source link

migration vue-router 0.7 data guard suggestion #825

Open frankOnTheWay opened 7 years ago

frankOnTheWay commented 7 years ago

For the data migration, it might be better using thenext callback in beforeRouteEnter to replace data for 2 reasons. First it can be triggered in create time, but watch cannot. (actually, I haven't know the details of watch.. I don't know where it placed in life-cycle diagram.) Second it has similar parameter like data hook. I tried the data fetching section's way but in created hook, I cannot get from . I am newbie to Vue but I am working on migration. And the reason I suggest this is that I have a keep-alive component and its data hook need from and this

chrisvfritz commented 7 years ago

Good point! I'll add a note that beforeRouteEnter may also be needed.