亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

路由是用名稱聲明的,但 this.$route.name : undefined
P粉555696738
P粉555696738 2024-03-27 10:20:02
0
1
489

我在 Django 項(xiàng)目之上使用 Vue3 CDN,在該項(xiàng)目中添加了 VueRouter,它工作得很好,直到我決定向路由對(duì)象添加名稱。

在我的主要組件內(nèi),我嘗試在用戶每次訪問頁面時(shí)檢查路由名稱的值。

const routes = [
{ 
    path: '/',
    name: 'home',
    component: home 
},
{
   path: '/our-program'
   name: 'program',
   component: 'program'
}
]

const router = VueRouter.createRouter({
history: VueRouter.createWebHashHistory(),
// mode: history,
routes,}); 


const app = Vue.createApp({
data() {
    return {}
},
 computed:{
    isFocus(){
        return this.$route.name;
    }
},
mounted() {
    console.log(this.$route);
    },
});

const vm = app.use(router).mount('#pages');

我在控制臺(tái)中獲取了路徑,但 $route.name 似乎無法通過。 難道沒有人知道我做錯(cuò)了什么嗎?

P粉555696738
P粉555696738

全部回復(fù)(1)
P粉545682500

this.$route.name 可以從子組件顯示,而不是像我試圖做的那樣從實(shí)際的根組件顯示。

最新下載
更多>
網(wǎng)站特效
網(wǎng)站源碼
網(wǎng)站素材
前端模板