vue单文件组件实例2:简单单文件组件

news/2024/7/10 0:02:02 标签: vue

Introduce.vue

<template>
  <div class="intro">
    单位介绍
  </div>
</template>

<script>

</script>

<style scoped>
.intro{
  font-size:20px;
  color:#000;
  margin:20px auto;
}
</style>

Employment.vue

<template>
  <div class="employment">
    人才引进
  </div>
</template>

<script>

</script>

<style scoped>
.employment{
  font-size:20px;
  color:#000;
  margin:20px auto;
}
</style>

Consult.vue

<template>
  <div class="consult">
    咨询
  </div>
</template>

<script>

</script>

<style scoped>
.consult{
  font-size:20px;
  color:#000;
  margin:20px auto;
}
</style>

Header.vue

<template>
  <div class="header">
    <div class="header-wrapper">
      <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{
    height:60px;
    color:#fff;
    background: #42b983;
  }
  .header-wrapper{
    height:60px;
  }
  .nav{
    width:700px;
    height:60px;
    font-size:15px;
  }
  .nav li{
    float:left;
    margin-right:60px;
    height:60px;
    line-height:60px;
    overflow:hidden;
  }
  .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>

Home.vue

<template>
  <div class="home">
    首页
  </div>
</template>

<script>

</script>

<style scoped>
.home{
  font-size:20px;
  color:#000;
  margin:20px auto;
}
</style>

App.vue

<template>
  <div id="vue">
    <div class="nav-top">
      <!-- 引入公用的头部 header组件 -->
      <v-header></v-header>
    </div>
    <div class="contianer">
      <!-- 路由中的几个组件在这里被渲染,默认被渲染的为第一个组件,也就是home组件  -->
      <router-view></router-view>
    </div>
  </div>
</template>
<style>
#vue {
  font-family: 'Avenir', Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
}
</style>
<script>
//引入header组件
import header from './components/Header.vue'
//输出header组件
export default{
  components: {
    'v-header': header
  }
}
</script>

main.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 }
})

 


http://www.niftyadmin.cn/n/887085.html

相关文章

android自定义缩放,android – SurfaceView使用自定义相机缩放IN和OUT功能

我已经编写了使用Custom Camera的代码,为此我使用的是SurfaceView,现在我想知道如果我需要实现Zoom IN和OUT功能,我从未使用过这种应用程序.我的代码,我用来创建自定义相机,见下文&#xff1a;MainActivity.java:-public class MainActivity extends Activity {private Surface…

ip地址配置 mongodb_在阿里云上安装MongoDB,并且远程连接

本文涉及到的东西:阿里云服务器ECSCentOs 7.4系统MongoDB 3.6大年初五了&#xff0c;还不赶紧用六十四卦摇一摇啊&#xff1f;看看新年财运如何~福利就要写在最前面&#xff1a; 过大年了&#xff0c;大家是不是又有了压岁钱了啊&#xff1f;&#xff1f;啊哈哈哈哈&#xff0c…

vue路由1:基本使用

路由&#xff0c;其实就是指向的意思&#xff0c;当我点击页面上的home按钮时&#xff0c;页面中就要显示home的内容&#xff0c;如果点击页面上的about 按钮&#xff0c;页面中就要显示about 的内容。Home按钮 > home 内容&#xff0c; about按钮 > about 内容&#xf…

怎么判断间隙过渡过盈配合_轴承与轴、轴承与孔的公差配合

分享一篇关于轴承公差配合的文章做非标这么久&#xff0c;轴承与轴的公差配合&#xff0c;以及轴承与孔的公差配合&#xff0c;一直都是用微小间隙配合即能实现功能&#xff0c;且好装好拆。但是局部零件还是需要有一定的配合精度。配合公差(fit tolerance)是指组成配合的孔、轴…

谷歌回应华为发布鸿蒙,被谷歌“除名”后,华为官宣:将发布鸿蒙手机版,如今已无所畏惧...

与电脑系统类似&#xff0c;手机操作系统如今也已经被安卓和苹果的iOS瓜分殆尽&#xff0c;根据数据&#xff0c;安卓和iOS已经占据了手机操作系统99%以上的市场份额。不过由于iOS是苹果自研的封闭系统&#xff0c;所以在智能手机这么多年发展下来&#xff0c;也就自然地形成了…

vue教程:数据与方法

当一个 Vue 实例被创建时&#xff0c;它向 Vue 的响应式系统中加入了其 data 对象中能找到的所有的属性。当这些属性的值发生改变时&#xff0c;视图将会产生“响应”&#xff0c;即匹配更新为新的值。 // 我们的数据对象 var data { a: 1 }// 该对象被加入到一个 Vue 实例中…

git log 只看当前分支_学会这些,99.9%的git问题都可以轻松解决

Git是一款免费并且开源的分布式版本控制系统&#xff0c;旨在快速高效地处理各种大小型项目的内容变更。相比CVS和SubVersion等集中式版本控制软件&#xff0c;Git更安全&#xff0c;也更强大。本文要求你有一定的Git基础(曾经用过、知道Git能干什么)。安装一切都要从安装开始&…

android关闭系统分享,谷歌 Android 12 将禁止第三方分享 App,默认使用原生接口

IT之家 5 月 28 日消息 许多 Android App 都支持分享功能&#xff0c;当用户点击分享按钮&#xff0c;如果没有自行实现分享功能&#xff0c;就会调用 Android 系统的分享功能。此外&#xff0c;市面上也有许多第三方分享 App&#xff0c;在功能上更加易用&#xff0c;可以用来…