我的單頁應(yīng)用程序從 Express 端點檢索組織數(shù)據(jù),并列出登錄用戶帳戶可用的不同組織。getUser是一個 vuex getter。組織名單打印得很好。當(dāng)我簽入 Vue 檢查器插件時,下面的代碼將組織 slug (org.slug) 顯示為每個組織的路由器鏈接上的參數(shù)。但編譯后的 html(dev 模式)無法反映單個 slug 參數(shù)。所有鏈接都顯示相同的a href="..."元素,指向數(shù)組中索引 0 處的第一個組織 slug。只有 org.slug 值在 v-for 循環(huán)/列表中重復(fù)。org.name 和 org.id 正確。<li v-for="org in getUser.organizations" :key="org.id"> <router-link :to="{ name: 'dashboard', params: org.slug }"> {{ org.name }} </router-link></li>在 Vue 檢查器中:props ariaCurrentValue:"page" custom:false to:Object name:"dashboard" params:"my-organization-0" // this changes to -1, -2, etc depending on the list item in the list路由器視圖:const routes = [ { path: '/login', name: 'login', component: Login, meta: { publicRoute: true } }, { path: '/:slug/dashboard', name: 'dashboard', component: () => import(/* webpackChunkName: "dashboard" */'../views/Dashboard.vue') }, { ...etc. }]你們有人看到我做錯了什么嗎?謝謝你的建議!
Vue 3 與 Vue Router:路由器鏈接具有正確的 Vue 參數(shù),但未反映在 HTML 中
慕田峪4524236
2023-09-07 16:20:19