命名视图

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div id="app">
    <div>
        <router-link to="/">首页</router-link>
        <router-link to="/user">用户管理</router-link>
        <router-link to="/post">帖子管理</router-link>
    </div>
    <div>
        <router-view></router-view>
        <router-view name="sidebar"></router-view>
        <router-view name="content"></router-view>
    </div>
</div>
<script src="../../lib/vue.js"></script>
<script src="../../lib/vue-router.js"></script>
<script src="js/main.js"></script>
</body>
</html>
var routes = [
    {
        path: "/",
        component: {
            template: `
            <h1>首页管理</h1>
            `
        }
    },
    {
        path:"/user",
        components:{
            sidebar:{
                template:`
                <div>
                <ul>
                <li>用户列表</li>
                <li>权限管理</li>
</ul>
</div>
                `
            },
            content:{
                template:`
                <div>
                主要的文本去,分区
</div>
                `
            }
        }
    },
    {
        path:"/post",
        components:{
            sidebar:{
                template:`
                <div>
                <ul>
                <li>帖子列表</li>
                <li>帖子管理</li>
</ul>
</div>
                `
            },
            content:{
                template:`
                <div>
                主要的文本去,分区
</div>
                `
            }
        }
    }


];

var router = new VueRouter({
    routes: routes
});
new Vue({
    el: "#app",
    router: router,
})

 

posted @ 2018-01-30 22:20  一石数字欠我15w!!!  阅读(139)  评论(0编辑  收藏  举报