Vue项目实战之旅游网站首页开发一

 安装stylus方便我们快速编写CSS代码

npm install stylus --save
npm install stylus-loader --save

在Home中导入并使用HomeHeader组件 

<template>
  <div>
    <home-header></home-header>
  </div>
</template>

<script>
import HomeHeader from './components/Header'
export default {
  name: 'Home',
  components: {
    HomeHeader
  }
}
</script>

<style scoped>

</style>

接下来该写Header组件中的代码了

<template>
  <div class="header">
    <div class="header-left">返回</div>
    <div class="header-input">输入城市/景点/游玩主题</div>
    <div class="header-right">城市</div>
  </div>
</template>

<script>
export default {
  name: 'HomeHeader'
}
</script>

<style lang="stylus" scoped>
  //1rem = html font-size = 50px
  //rem以字体大小为参考值,reset.css中字体大小为50px,设计图为2倍尺寸图,即86/100
  .header
    display: flex
    line-height: 0.86rem
    background: #00bcd4
    color: #fff
    .head-left
      width: 0.64rem
      float: left
    .header-input
      flex: 1
      height: 0.64rem
      line-height: 0.64rem
      margin-top: 0.12rem
      margin-left: 0.2rem
      background: #fff
      border-radius: 0.1rem
      color: #ccc
    .header-right
      width: 1.24rem
      float: right
      text-align: center

</style>

实现首页Header组件效果

Vue项目实战之旅游网站首页开发一