前端vue2实现头部组件(自定义背景icon+抽屉式使用指南展示)

本文介绍了如何在Vue2中创建一个可全局复用的头部组件`OperatingGuide.vue`,该组件包含自定义背景图、抽屉式使用指南。组件结构包括左侧文字栏、中间图标和右侧的使用指南按钮,点击按钮会显示一个从右侧滑出的使用说明drawer。此外,文章还提供了页面使用该组件的示例代码。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

一、文章引导

自定义背景icon+抽屉式使用指南展示
页面使用
OperatingGuide.vue组件

二、博主简介

🌏博客首页: 水香木鱼
📌专栏收录:后台管理
📑文章摘要:vue2后台管理组件化重复使用CSS3
💌木鱼寄语:故木秀于林,风必摧之;堆出于岸,流必湍之;行高于人,众必非之。


三、文章内容

本期木鱼为大家分享的是,前端vue2实现头部组件【可全局复用】

在这里插入图片描述

①、OperatingGuide.vue 组件

  • 使用指南 小icon 需要自行替换
<!--使用指南-->
<template>
  <div class="intro">
    <!-- 左侧文字栏 -->
    <div class="intro-text">
      <div class="main">
        <span class="word1">{{ data.name }}</span>
        <span class="info1">{{ data.intro }}</span>
        <div class="layer"></div>
      </div>
    </div>
    <!-- 中间图标 -->
    <div class="intro-pic">
      <!-- 背景icon 自行去替换 -->
      <img :src="data.img" />
    </div>
    <!-- 右侧 文字提示 -->
    <div class="intro-guide" @click="showGuide">
      <!-- icon 自行去替换 -->
      <img
        class="icon1"
        referrerpolicy="no-referrer"
        src="@/assets/icon_guide.png"
      />
      <span class="title1">使用指南</span>
    </div>
    <!-- 显示-使用指南 -->
    <el-drawer
      :visible.sync="guideVisible"
      :with-header="false"
      :direction="'rtl'"
      size="30%"
    >
      <div class="guide">
        <div class="guide-title">开发环境</div>
        <div class="guide-content">
          <p>演示环境介绍</p>
          <p>演示文字.....................................</p>
          <p>演示文字.....................................</p>
          <p>演示文字.....................................</p>
          <p>演示文字.....................................</p>
          <p>演示文字.....................................</p>
        </div>
      </div>
    </el-drawer>
  </div>
</template>

<script>
export default {
  name: "OperatingGuide",
  props: ["data"],
  data() {
    return {
      guideVisible: false,
    };
  },
  methods: {
    showGuide() {
      this.guideVisible = true;
    },
  },
};
</script>

<style lang="less" scoped>
.intro {
  width: 100%;
  height: 200px;
  border-radius: 2px;
  background: linear-gradient(83deg, #ffffff 0%, #f4f8ff 100%);
  position: relative;
  display: flex;
  &-text {
    margin: 41px 0px 20px 51px;
    width: 60%;
    .main {
      width: 97%;
      .word1 {
        width: 100%;
        height: 28px;
        display: block;
        overflow-wrap: break-word;
        color: rgba(66, 70, 86, 1);
        font-size: 20px;
        text-transform: uppercase;
        font-family: PingFangSC-Heavy;
        white-space: nowrap;
        line-height: 28px;
        text-align: left;
      }
      .info1 {
        width: 100%;
        max-height: 68px;
        display: block;
        overflow-wrap: break-word;
        color: rgba(66, 70, 86, 1);
        font-size: 13px;
        text-transform: uppercase;
        line-height: 17px;
        text-align: left;
        margin-top: 10px;
        overflow: hidden;
        text-overflow: ellipsis;
      }
      .layer {
        width: 46px;
        height: 5px;
        border-radius: 2.5px 0 0 2.5px;
        background-image: linear-gradient(
          90deg,
          rgb(124, 70, 7) 0%,
          rgba(254, 254, 255, 0) 100%
        );
        margin-top: 10px;
      }
    }
  }
  &-pic {
    width: 20%;
    img {
      max-width: 100%;
      max-height: 100%;
    }
  }
  &-guide {
    height: 38px;
    margin: 12px 30px;
    text-align: right;
    cursor: pointer;
    .icon1 {
      width: 16px;
      height: 16px;
      margin: -4px 4px -4px -4px;
    }
    .title1 {
      height: 17px;
      display: inline-block;
      overflow-wrap: break-word;
      color: rgba(66, 70, 86, 1);
      font-size: 12px;
      text-transform: uppercase;
      white-space: nowrap;
      line-height: 17px;
    }
  }
}
.intro-guide {
  display: flex;
  align-items: center;
}
.guide {
  padding: 20px 32px;
  &-title {
    font-size: 15px;
    font-weight: 600;
    line-height: 36px;
  }
  &-content p {
    line-height: 22px;
    margin-bottom: 13px;
    font-size: 13px;
  }
}
</style>

②、页面使用方式

<template>
  <div>
    <OperatingGuide :data="intro"></OperatingGuide>
  </div>
</template>
<script>
import OperatingGuide from "../../components/OperatingGuide.vue";
export default {
  components: {
    OperatingGuide,
  },
  data() {
    return {
      // 顶部介绍
      intro: {
        name: "演示仓库",
        intro: "演示文字简介...........................",
        img: require("@/assets/warehouse.png"),//需要自行替换背景icon
      },
    };
  },
};
</script>

四、程序语录

信念和目标,必须永远洋溢在程序员内心!

五、精彩推荐

💡前端Vue中实现超炫酷动态背景(全屏背景+自定义banner+登录/注册页)
💡前端vue3+typescript搭建vite项目(初识vite+项目配置完善+屏幕适配)
💡前端vue中ts无法识别引入的vue文件,提示找不到xxx.vue模块的解决【引入新建页面或者通过router引入时报错】
💡vue实现修改title提示框-默认样式【两种方式】
💡vue封装全屏组件【无插件操作】


本篇博客文章模板唯一版权归属©水香木鱼

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

水香木鱼

你的鼓励将是我创作的最大动力

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

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

打赏作者

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

抵扣说明:

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

余额充值