我正在尝试迭代一些数据以生成我的router-link
s
<router-link v-for="(data, dataKey) in dataObject"
:to="{ params: { dataKey: dataKey }}"
tag="li">
<a>
<span>
{{ dataKey }}
</span>
</a>
</router-link>
这会使用正确的字符串创建标记,但如果我不是我尝试构建的链接之一,则不会将dataKey
附加到链接。
dataKey
甚至可以在<span>
</span>
但是,当我手动导航到其中一个链接时,所有参数都被正确附加。
export const routes = [
{ path: '/', component: Home, beforeEnter: checkAuthentication },
{ path: '/dashboard',
component: Dashboard,
children: [
{
path: '',
component: DashboardHome,
name: 'Dashboard Home'
},
{
path: 'profile',
component: DashboardPhotos,
children: [
{
path: '',
component: DashboardPhotosHome,
name: 'Dashboard Profile Home'
},
{
path: ':dataKey',
component: PhotoViewer,
props: true
}
]
},