Vue學堂 通過路徑傳遞參數

router.js跳轉設置參數

 {
    path: '/profile/:fcId',
    component: Profile
}

跳轉到頁面獲取參數

this.$route.params.fcId;

通過url後攜帶參數設置

第二種設置方式

this.$router.push({path: '/info?name=' + name});

獲取參數

this.$route.query.name

通過json數據傳遞

設置方式

this.$router.push({path: '/info', query:{age: 24}});

獲取方式

this.$route.query.age;
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章