vuejs / vue-async-data

Async data loading plugin
MIT License
416 stars 38 forks source link

Usage with Vue 2 & vue-router 2 #22

Closed dwightjack closed 8 years ago

dwightjack commented 8 years ago

Hi,

looking at this example for data fetching with vue-router v2+ I understand that the async data option has been removed and a pattern for async data very similar to this project is in use.

I'm refactoring a vue 1.x project with migration to v2 in mind, so I was wondering if my assumption is true and whether it'd be an option to adapt this plugin to work with 2.x

If so I'd might also be able to take care of the task and make a PR

LinusBorg commented 8 years ago

Have a look at the examples in vue-router's next branch:

To fetch data after the new route component has been entered, use this approach:

https://github.com/vuejs/vue-router/blob/next/examples/data-fetching/Post.vue#L31-L36

If you want to hold off with the transition until the data was fetched, use the beforeRouteEnter hook:

https://github.com/vuejs/vue-router/blob/next/examples/navigation-guards/app.js#L50-L64

dwightjack commented 8 years ago

Hi thabks for the reply.

So I need to call fect both on created and on route change? Or the route change oa just in place because of the id params?

LinusBorg commented 8 years ago

Or the route change oa just in place because of the id params?

That's correct

dwightjack commented 8 years ago

Ok thank you again!

cnweibo commented 8 years ago

For simpler applicaion, i do not want to use vue-router. In such case, how can i use vue-async-data plugin in vuejs2.0 environment?