您的位置:首页 > 其它

路由--命名视图实现经典布局

2020-01-14 15:34 106 查看

路由–命名视图实现经典布局

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Title</title>
<script src="https://cdn.staticfile.org/vue/2.6.10/vue.js"></script>
<script src="https://cdn.staticfile.org/vue-router/2.7.0/vue-router.js"></script>
<style>
html,body{
margin: 0;
padding: 0;
}
.header {
background-color: orange;
height: 100px;
margin: 0 auto;
}
h1{
margin: 0;
padding: 0;
font-size: 16px;
}
.container{
display: flex;
height: 531px;
}
.left{
background-color: #42b983;
flex: 2;
}
.main{
background-color: white;
flex: 8;
}
</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>
<script>
var header = {
template: '<h1 class="header">Header头部区域hhhh</h1>'
}
var leftBox = {
template: '<h1 class="left">Left区域</h1>'
}
var mainBox = {
template: '<h1 class="main">mainBox主体区域</h1>'
}
var router = new VueRouter({
routes: [
// {path:'/',component:header},
// {path:'/left',component:leftBox},
// {path:'/main',component:mainBox}
{
path: '/', components: {
'default': header,
'left': leftBox,
'main': mainBox
}
}
]
})
var vm = new Vue({
el: '#app',
data: {},
methods: {},
router: router
})
</script>
</body>
</html>
  • 点赞
  • 收藏
  • 分享
  • 文章举报
qweryitao 发布了23 篇原创文章 · 获赞 0 · 访问量 67 私信 关注
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: