[Vuejs]-Refreshing page on child route doesn't show the data for just that route

0👍

Your problem is because you only make an ajax call when the the year view is called. If you go directly to 2002 view there is no ajax call thus no data to load the page. If you add the an ajax call to the 2002 view you can go directly to the page and see data. It looks like your are using a PWA format which I am not very familiar with but if I were doing this I would make your year.vue view the main component and them then make a child component that populates the data for the year that way you can pass down the chain using props and not have any problems. Also I would into Arrow Syntax which would eliminate the need for const self = this; amongst other things, you could just use this. Also it is bad practice to load data for a bunch of components at once, its fine in your example but what would happen if you had 30 years of data your initial load would probably be terribly slow. Load what you need on each call and make multiple calls. If your data doesn’t change much you can look into caching it instead of making multiple calls all the time

👤Taylor

Leave a comment