美文网首页
Vue在页面布局分为上中下三部分

Vue在页面布局分为上中下三部分

作者: ___大鱼___ | 来源:发表于2018-11-18 14:22 被阅读29次
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<script src="https://unpkg.com/vue/dist/vue.js"></script>
<script src="https://unpkg.com/vue-router/dist/vue-router.js"></script>

<style>
    html, body{
        margin: 0;
        padding: 0;
    }
    .header{
        width: 100%;
        height: 150px;
        background-color: blueviolet;

    }
    h1{
        margin: 0;
        padding: 0;
    }


    .content{
        display: flex;
        height: 572px;
    }
    .left{
        flex: 2;
        background-color: #1392e9;
    }
    .mainBox{
        flex: 8;
        background-color: #60ac39;
    }

</style>
<body>

<div id="container">
 <router-view class="header"></router-view>
    <div class="content">
        <div class="left">
         <router-view name="left"></router-view>

        </div>
        <div class="mainBox">
     <router-view name="mainBox"></router-view>

        </div>
    </div>

</div>


<script>

    var header = {
        template: '<h1>头部内容</h1>'
    }

    var left = {
        template: '<h1>左侧内容</h1>'
    }

    var mainBox = {
        template: '<h1>主要内容</h1>'
    }



    var router = new VueRouter({
        routes:[
            {path: '/', components: {
                'default': header,
                'left': left,
                'mainBox': mainBox,
            }
            }
        ]
    })


    var app1 = new Vue({
        el: '#container',
        data:{
            list:[1,3,4]
        },
        router



    })


</script>





</body>

</html>

相关文章

网友评论

      本文标题:Vue在页面布局分为上中下三部分

      本文链接:https://www.haomeiwen.com/subject/mekgfqtx.html