// 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>