vue解決二級路由redirect(默認路由)不傳參的問題


場景:

pageA----pageB(pageB包含三個二級路由)       

默認進入pageB時進入第一個頁面的路由,之后點擊左側按鈕,分別進入其他二級路由

原router.js寫法:

//應用信息
    {
        path:'/app-manage',
        name:'app-manage',
        component:AppManage,
        redirect:'/app-manage/appMsg',
        children:[
            //應用信息
            {
                path:'/app-manage/appMsg',
                name:'appMsg',
                component:AppMsg,
            },
            ...其他子路由...
        ]
    },
頁面路由跳轉寫法:
<router-link class="lis" tag="li" v-for="(item,index) in side" :to="{path:item.url,query:{appMsg}}" :key="index">
       {{item.name}}
</router-link>
問題,一次進入默認路由時,不傳遞參數,只有在之后的點擊第一個路由時才傳遞
解決方法:
1.去除router.js的redirect屬性
2.在pageB頁面第一次頁面加載請求到數據后添加
let appMsg = this.appMsg
 this.$router.push({path:'/app-manage/appMsg',query:{appMsg}})


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM