vue.js单页面应用实例
// The Vue build version to load with the `import` command // (runtime-only or standalone) has been set in webpack.base.conf with an alias. import Vue from 'vue' import App from './App' // 引入router路由 import Router from 'vue-router' // 引入项目的四个模块组件 import introduce from './components/introduce' import home from './components/home' import employment from './components/employment' import consult from './components/consult' // 使用router Vue.use(Router) // 定义路由 var routes = [{path: '/home',component: home }, {path: '/introduce',component: introduce }, {path: '/employment',component: employment }, {path: '/consult',component: consult }] // 实例化路由 var vueRouter = new Router({routes }) // 创建和挂载根实例 new Vue({el: '#app',router: vueRouter,template: '<App></App>',components: { App } })
<template><div id="app"><div class="nav-top"><!-- 引入公用的头部 header组件 --><v-header></v-header></div><div class="banner"></div><div class="contianer"><!-- 路由中的几个组件在这里被渲染,默认被渲染的为第一个组件,也就是home组件 --><router-view></router-view></div></div> </template> <style> #app {font-family: 'Avenir', Helvetica, Arial, sans-serif;-webkit-font-smoothing: antialiased;-moz-osx-font-smoothing: grayscale;text-align: center;color: #2c3e50; } .nav-top {position: absolute;top: 0;left: 50%;margin-left: -600px;z-index: 99; } .banner{width: 100%;height: 370px;overflow: hidden;background: url("components/banner.jpg");background-repeat: no-repeat; } </style> <script> //引入header组件 import header from './components/header.vue' //输出header组件 export default{components: {'v-header': header} } </script>
<template><div class="header"><div class="header-wrapper"><div class="logo"><a href="/home"><img src="../assets/ysh.png" alt width="210"></a></div><ul class="nav"><li><router-link to="/home">首页</router-link></li><li><router-link to="/introduce">公司介绍</router-link></li><li><router-link to="/employment">招贤纳士</router-link></li><li><router-link to="/consult">易点咨询</router-link></li></ul> </div> </div> </template> <style> .header{width:1200px;height:100px;margin:0 auto;color:#fff; } .header-wrapper{width:1200px;height:100px; } .logo{width:210px;height:100px;float:left; } .nav{width:700px;height:100px;font-size:15px;float:right; } .nav li{float:left;margin-right:30px;height:34px;line-height:34px;overflow:hidden;margin-top:34px; } .nav li:last-child{margin-right:0; } .nav a{display:inline-block;padding:0 13px;color:#fff;border-radius:15px; } .nav a.router-link-active{background:#c10514; } </style>
<template> <div class="intro"> 公司介绍 </div> <div> zx </div> </template> <style> .intro{font-size:20px;color:#000;margin:20px auto; } </style>
<template><div class="intro">公司介绍</div> </template> <style> .intro{font-size:20px;color:#000;margin:20px auto; } </style>
转载于:https://www.cnblogs.com/weiyemo/p/6591334.html
vue.js单页面应用实例相关推荐
- 新手vue构建单页面应用实例
本人写的小程序,功能还在完善中,欢迎扫一扫提出宝贵意见! 步骤: 1.使用vue-cli创建项目 2.使用vue-router实现单页路由 3.用vuex管理我们的数据流 4.使用 ...
- vue 扫码页面限制区域_Vue.js 单页面多路由区域操作的实例详解
单页面多路由区域操作 在一个页面中有两个及以上的区域,需要通过设置路由的index.js,来操作这些区域的内容 app.vue 中设置: index.js中设置: import vue from 'v ...
- vue重构html css,使用vue重构资讯页面的实例代码解析
从我接手到将这个页面代码重构前,一直都还是使用angular1的代码去做的,需求来了也是用angular去实现:作为一个憧憬新技术的前端,怎么忍受得了现在还在使用这么有历史感的框架,所以,以前就一直在 ...
- vue 加载页面时触发时间_详解Vue.js在页面加载时执行某个方法
详解Vue.js在页面加载时执行某个方法 jQuery中可以这样写 vue中,如果要达到相同效果,可以使用vue的生命周期函数,如create或者mounted 附上vue.js的生命周期函数执行流程 ...
- Java快速开发平台,JEECG 3.7.5 Vue SPA单页面应用版本发布
JEECG 3.7.5 Vue SPA单页面应用版本发布 导读 ⊙ Vue+ElementUI SPA单页面应用 ⊙Datagrid标签快速切换BootstrapTable列表风 ...
- [vue] SPA单页面的实现方式有哪些?
[vue] SPA单页面的实现方式有哪些? 1.监听地址栏中hash变化驱动界面变化2.用pushsate记录浏览器的历史,驱动界面发送变化3.直接在界面用普通事件驱动界面变化它们都是遵循同一种原则: ...
- 纯js单页面赛车游戏
纯js单页面赛车游戏 这次就是给大家分享赛车的游戏: 废话不多,直接上代码: <!DOCTYPE html> <html> <head><meta chars ...
- Vue.js进阶【3】纯Vue实现单页面-列表增删改查
增删改查最能代表一个技术的完备性的,下面就展示Vue的增删改查,为了界面的美观实用了bootstrap 仔细阅读下面的代码,即可领会其意思.不懂的标签和元素百度查一下一查一大堆.很快就可以理解了 运行 ...
- vue实现div多选全选功能_怎样为你的 Vue.js 单页应用提速
每日前端夜话第323篇 翻译:疯狂的技术宅 作者:Matthias Sommer 来源:dzone 正文共:1956 字 预计阅读时间:10 分钟 我有一个项目用了 Vue.js 来构建单页应用程序. ...
最新文章
- POJ2387 Til the Cows Come Home -DIJKSTRA 练习
- 数据库路由中间件MyCat - 使用篇(2)
- 获取手机idfa_七麦线上公开课:后IDFA时代,链接用户的新生态解决方案
- Filtering microblogging messages for Social TV
- android 数据库 字节数组,Android上的GreenDAO:字节数组作为主键/构建包含字节数组属性Where子句的查询...
- Hbase学习-一步一步慢慢来
- unity最基本操作
- webstrom 里面使用github
- MySQL循环结构例题_Mysql:循环结构
- SQL Server无法连接客户端的问题
- 最历害的硬盘修复工具PC3000,可重置SMART状态!
- VS软件设置中的宏定义
- AI制作ICON流程
- photoshop技巧分享:psd格式批量转换jpg格式一键完成
- 制定科学学习计划的重要性
- 2022天梯赛 L1-087 机工士姆斯塔迪奥
- EDK环境搭建UEFI工程模块文件介绍
- R语言多层桑基图_流量结构分布图——桑基图(Sankey)
- torch.nn.Conv2d() 用法讲解
- 关于凸函数求最大值的下标的小讨论(斐波那契优选法/二分法/三分法)
热门文章
- python结束进程树_【python爬虫】线程进程
- 深度学习(25)随机梯度下降三: 激活函数的梯度
- 看了就会的VScode给C++的配置编译环境(Visual Studio Code)
- CF思维联系--CodeForces - 218C E - Ice Skating (并查集)
- USACO Training Section 1.1黑色星期五Friday the Thirteenth
- lwIP ARP协议分析
- 【卷积核设计】Scaling Up Your Kernels to 31x31: Revisiting Large Kernel Design in CNNs
- 【语义分割】ICCV21_Mining Contextual Information Beyond Image for Semantic Segmentation
- 梯度下降法_梯度下降
- 人工智能已经迫在眉睫_创意计算机已经迫在眉睫