Description
Vue.js / vue-router versions
2.2.4 / 2.3.0
Summary
This is difficult to explain, but hopefully the steps below will help you see the issue. The path
property of a generated <router-link>
appears to be work fine the first time it is called. After visiting the generated link and returning to the page which generates the link, the path
appears to be cached to the original generated link that you clicked on and does not accurately reflect the params
being passed to it.
Reproduction Link
http://217.182.65.138:8080
Note: App is running in yarn run dev
mode, so you can see the application source files through your browser dev tools. This may assist you with debugging the issue if necessary.
Steps to reproduce
- Visit Leaderboards page
- Wait for table data to load
- Once loaded, hover over each user to see that routes are correctly generated (/:username/:platform/overview)
- Click one of the users to follow the link
- Return to the Leaderboards page (you don't need to wait for the data on the new page to load)
What is Expected?
Once the table data on the Leaderboards page reloads, the links should still generate correctly.
What is actually happening?
Once the table data on the Leaderboards page reloads, all of the links point to the user you originally clicked on during the reproduction steps. The Chrome Vue dev tools plugin also shows the links with the correct params
but the path
appears to have been cached somehow to the user you originally clicked on.
Notes
I am not doing anything special for the links. The route is configured like this:
// Individual Player Stats
{
path: '/:username/:platform',
name: 'stats',
component: Stats,
redirect: {
name: 'stats.overview'
},
meta: {
breadcrumb: 'Stats'
},
children: [
{ path: 'overview', name: 'stats.overview', component: OverviewStats, meta: { breadcrumb: 'Overview' } },
{ path: 'operators', name: 'stats.operators', component: OperatorStats, meta: { breadcrumb: 'Operators' } },
{ path: 'rolling-data', name: 'stats.rolling-data', component: RollingDataStats, meta: { breadcrumb: 'Rolling Data' } }
]
}
I generate the links to that page from the Leaderboards page through a v-for
loop (where the data being looped through comes from an API call) like this:
<tr v-for="(player, i) in leaderboard" :key="player.ubisoft_id">
<td>{{ activeRecordsStart + i }}</td>
<td>
<router-link :to="{
name: 'stats.overview',
params: {
username: player.username,
platform: player.platform
}
}">
{{ player.username }}
</router-link>
</td>
<!-- etc -->
</tr>
I believe this is a bug but it may be an issue with our setup. Any assistance with identifying the cause would be highly appreciated, even if it is not necessarily confirmed as a bug in the end.