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

<!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>
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容