5,头部Header组件 ly-tab插件的使用

components 下新建home文件夹

添加header.vue组件

<template>
  <header>
    <h1>荼七网</h1>
    <div class="search">
      <i class="iconfont icon-RectangleCopy"></i>
      <span>猜你喜欢</span>
    </div>
    <div class="kufu">
      <i class="iconfont icon-yonghu"></i>
    </div>
  </header>
</template>

<script>
export default {};
</script>

<style scoped>
header {
  display: flex;
  justify-content: space-around;
  align-items: center;
  position: fixed;

  top: 0;
  left: 0;
  width: 100%;
  height: 1.2267rem;
  background-color: #4ac23f;
}
header h1 {
  display: flex;
  font-size: 0.6267rem;
  color: #fff;
  padding: 0 0.1rem;
  align-items: center;

  height: 1.173333rem;
}
header h1 img {
  width: 100%;
  height: 100%;
}
.search {
  display: flex;
  align-items: center;
  width: 6.56rem;
  height: 0.8rem;
  background-color: #fff;
  border-radius: 12px;
}
.search i {
  padding: 0 0.16rem;
  color: #ccc;
  font-size: 0.7533rem;
}
.search span {
  padding: 0 0.06rem;
  color: #ccc;
  font-size: 0.4533rem;
}
.kufu i {
  font-size: 0.76rem;
  color: #fff;
}
</style>
Ly-tab

一个用于移动端的可触摸滑动具有回弹效果的可复用Vue组件
安装
npm i ly-tab -S

引入

import Vue from 'vue'
import LyTab from 'ly-tab'

Vue.use(LyTab)
// 之后便可在全局使用了

在home页使用

<template>
  <div class="home">
    <Tabbar />
    <Header />
    <ly-tab v-model="selectedId" :items="items" :options="options"> </ly-tab>
  </div>
</template>

<script>
import Tabbar from "@/components/common/Tabbar.vue";
import Header from "@/components/home/Header.vue";
export default {
  components: {
    Tabbar,
    Header,
  },
  name: "Home",
  data() {
    return {
      selectedId: 0,
      items: [
        { label: "首页" },
        { label: "推荐" },
        { label: "Android" },
        { label: "前端" },
        { label: "后端" },
        { label: "iOS" },
        { label: "产品" },
        { label: "人工智能" },
        { label: "设计" },
      ],
      options: {
        activeColor: "#4ac23f",
        // 可在这里指定labelKey为你数据里文字对应的字段
      },
    };
  },
};
</script>

<style scoped>
.ly-tab {
  position: fixed;
  top: 1.2rem;
  left: 0;
}
::v-deep .ly-tab {
  box-shadow: none;
  border-bottom: none;
}
</style>

效果:

 

  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 6
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值