其他分享
首页 > 其他分享> > 千峰商城-springboot项目搭建-46-router嵌套路由

千峰商城-springboot项目搭建-46-router嵌套路由

作者:互联网

嵌套路由:当我们点击一个链接,就会显示一个组件。在一级路由的组件中显示二级路由就是嵌套路由。  
<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
        <script type="text/javascript" src="js/vue.js" ></script>
        <script type="text/javascript" src="js/vue-router.js"></script>
    </head>
    <body>
        <div id="container">
            <router-link to="/a">首页</router-link>
            <router-link to="/a/c1">首页-c1</router-link>
            <router-link to="/a/c2">首页-c1</router-link>
            <router-view></router-view>
        </div>
        
        <script type="text/javascript">
            
            const t1 = {
                template:`<div style="width:400px; height:200px; border:blue 1px solid">
                index
                <hr />
                <router-view></router-view>
                </div>`
                };
                
                const t2 = {template:`<div>t2</div>`};
                const t3 = {template:`<div>t3</div>`};

            const myrouter = new VueRouter({
                routes:[
                    {
                        path:"/a",
                        component:t1,
                        //children:二级路由
                        children:[
                            {path:"c1",
                            component:t2},
                            {path:"c2",
                            component:t3}
                        ]
                    },
            ]});

            var vm = new Vue({
                el:"#container",
                router:myrouter
            });
        </script>
    </body>
</html>

 

 

 

 

 

 

 

 

 

 

 

   

标签:const,springboot,46,component,template,path,router,c1,路由
来源: https://www.cnblogs.com/lysboke/p/16469609.html