实现页面:

实现效果:

实现代码:

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<script type="text/javascript" src="js/vue.js" ></script>
<script type="text/javascript" src="js/vue-router.js" ></script>
<style type="text/css">
#app{width: 800px;margin: 0 auto;}
#banner{text-align: right;line-height: 40px;background-color: royalblue;color: #fff;padding: 0 10px;}
#container{display: flex;text-align: center;height: 500px;}
.index{flex: 10;background-color: lightblue;}
.article{flex:7;background-color: lightblue;}
.attention{flex:7;background-color: lightblue;}
.hot{flex:3;background-color: lightpink;}
</style>
</head>
<body>
<div id="app">
<div id="banner">
<router-link to="/index" tag="span">首页</router-link>
<router-link to="/article" tag="span">我的文章</router-link>
<router-link to="/attention" tag="span">我的关注</router-link>
</div>
<div id="container">
<router-view></router-view>
<router-view name="article"></router-view>
<router-view name="attention"></router-view>
<router-view name="hot"></router-view>
</div>
</div> <template id="index">
<div class="index">主体页面</div>
</template>
<template id="article">
<div class="article">文章列表页面</div>
</template>
<template id="attention">
<div class="attention">我的关注页面</div>
</template>
<template id="hot">
<div class="hot">热门文章推荐</div>
</template>
<script type="text/javascript">
var indexTemp = {template:"#index"}
var articleTemp = {template:"#article"}
var attentionTemp = {template:"#attention"}
var hotTemp = {template:"#hot"} Vue.component('index',indexTemp)
Vue.component('article',articleTemp)
Vue.component('attention',attentionTemp)
Vue.component('hot',hotTemp) var routerRules = new VueRouter({
routes:[
{path:'/index',component:indexTemp},
{
path:'/article',
components:{article:articleTemp,hot:hotTemp}
},
{
path:'/attention',
components:{attention:attentionTemp,hot:hotTemp}
},
]
})
var vm = new Vue({
el:"#app",
router:routerRules
})
</script>
</body>
</html>

最新文章

  1. iOS 导入第三方文件夹时右侧出现问号
  2. 号外号外:9月21号关于Speed-BI 《全国人口统计数据分析》开讲了
  3. Android 建造者(Builder)模式
  4. 用Python制作游戏外挂(上)
  5. iptables-过滤61开头的ip数据包
  6. FZU 2087 统计树边
  7. Spring+SpringMVC+MyBatis深入学习及搭建(三)——MyBatis全局配置文件解析
  8. iOS 应用开发,用户密码存储技术--KeyChain
  9. [luogu1168]中位数_优先队列
  10. C++——虚函数问题小集
  11. 5.list集合添加姓名{张三,李四,王五,二丫,钱六,孙七},将二丫替换为王小丫, 写入到&quot;D:\\stuinfo.txt&quot;
  12. 批量备份数据库脚本(PowerShell版)
  13. chrome浏览器添加vue-devtools扩展
  14. 文本分类学习 (八)SVM 入门之线性分类器
  15. Discrete Log Algorithms :Baby-step giant-step 【二】
  16. JavaScript基础-DAY2
  17. mysql 报错 ‘u&#39;Subquery returns more than 1 row&#39;’
  18. hdu 1233 还是畅通project
  19. GPU bubbles
  20. access与excel

热门文章

  1. 小白学 Python 数据分析(8):Pandas (七)数据预处理
  2. 多线程笔记 - disruptor
  3. 代理-cglib代理
  4. 安卓接入融云IM连接不上??
  5. redis 5.0.7 源码阅读——压缩列表ziplist
  6. ASP.NET Core DI概述
  7. 算法训练 最大获利 注意数据规模(long long)
  8. Treap总结
  9. 一个C语言程序是由( )组成?
  10. 走进MEasy的世界:基于STM32MP1的IOT参考设计