原 Vue实战中常见问题解决方案之----路由

1. 路由模板之--同时加载多个动态模块

router.js:

export default new Router({
    routes: [
        {
            path: '/',
            components:{
                a: Home,
                b: Guide
            }
        }
    ]
})

App.vue :

<template>
    <div id="app">
        <router-view name="a"></router-view>
        <router-view name="b"></router-view>
    </div>
</template>

总结:当一个页面需要加载多个动态组件时,通过 router-view  的name属性对应路由的配置就OK了!!!

猜你喜欢

转载自blog.csdn.net/github_37360787/article/details/81220096