六十五、完成Vue项目去哪儿网App首页开发(来源:慕课网)

2020/10/21、 周三、今天又是奋斗的一天。

@Author:Runsen
@Date:2020/10/21

写在前面:我是「Runsen」,热爱技术、热爱开源、热爱编程。技术是开源的、知识是共享的。大四弃算法转前端,需要每天的日积月累, 每天都要加油!!!

今天将完成Vue项目去哪儿网App首页开发,下面是在本次慕课网完成Vue项目去哪儿网App首页开发的总结和感受。

全局安装stylus和stylus-loader

在Vue中有三种CSS预处理,现在用的最多的是stylus。

下载安装stylus、stylus-loader包。

npm install stylus@0.54.5  --save
npm install stylus-loader@3.0.1 --save

package.json中就可以stylus和stylus-loader 对应的版本号。

在vscode的编写stylus,最好安装stylues的插件

创建iconfont项目

在阿里巴巴图标官方,创建iconfont项目,并添加所需的图标。下载到本地。

将对应的文件复制到对应的项目,并修改iconfont.css文件对应的路径。

Home.vue

在Home.vue引用HomeHeader ,HomeHeader 对应的<home-header>

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

<script>
// 局部组件需要插入到components中,由于键和值都是一样,所以写成HomeHeader
import HomeHeader from './components/Header'
export default {
  name: 'Home',
  components: {
    HomeHeader
  }
}
</script>

<style>
</style>

Header.vue

Header.vue就是首页开发的组件,将对应的图标引用。

在styles中1rem等于100px。px像素(Pixel)。相对长度单位。像素px是相对于显示器屏幕分辨率而言的。

对于需要适配各种移动设备,使用rem,因此前端开发基本用rem。

<template>
  <div class="header">
    <div class="header-left">
      <div class="iconfont back-icon">&#xe624;</div>
    </div>
    <div class="header-input">
      <span class="iconfont">&#xe602;</span>
      输入城市/景点/游玩主题
    </div>
    <div class="header-right">城市
      <span class="iconfont arrow-icon">&#xe658;</span>
    </div>
  </div>
</template>

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

<style lang="stylus" scoped>
@import '~styles/varibles.styl';
.header
  display: flex
  line-height: 0.86rem
  height: 0.86rem
  background: $bgColor
  color: #fff
  .header-left
    width: 0.64rem
    float: left
    .back-icon
      text-align: center
      font-style: 0.4rem
  .header-input
    flex: 1
    background: #fff
    height: 0.64rem
    line-height: 0.64rem
    margin-top: 0.12rem
    margin-left: 0.2rem
    boirder-radius: 0.1rem
    color: #ccc
  .header-right
    width: 1.24rem
    float: right
    text-align: center
    .arrow-icon
      margin-left: -0.04rem
      font-size: 0.24rem
</style>

配置webpack,对项目进行维护

webpack.base.conf.js中配置'styles': resolve('src/assets/styles'),。只要在import中出现了styles,代表就是src/assets/styles路径


具体实现效果如下。


参考课程:慕课网Vue2.5->2.6->3.0 开发去哪儿网App 从零基础入门到实战项目开发

请一键三连!!!!!
评论 17
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

小刘要努力。

顺便点一个赞

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值