通过路由实现经典布局
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>实现经典布局</title>
<script src="vue.js"></script>
<script src="vue-route.js"></script>
<style>
.header{
background-color: orange;
height: 80px;
}
.left{
background-color: lightcoral;
flex: 2;
}
.main{
background-color: lightblue;
flex: 8;
}
.container{
display: flex;
height: 600px;
}
h1{
margin: 0;
padding: 0;
font-size: 10px;
}
html, body{
margin: 0;
padding: 0;
}
</style>
</head>
<body>
<div id="app">
<router-view></router-view>
<div class="container">
<router-view name="left"></router-view>
<router-view name="main"></router-view>
</div>
</div>
</body>
<script>
var header = {
template: "<h1 class='header'>头部</h1>"
};
var left = {
template: "<h1 class='left'>左侧</h1>"
};
var main = {
template: "<h1 class='main'>主体</h1>"
};
var router = new VueRouter({
routes:[
{
path:'/',components:{
'default': header,
'left': left,
'main': main
}
}
]
});
var app = new Vue({
el:'#app',
router
})
</script>
</html>