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