当前位置:   article > 正文

vue3实现渐近伸缩抽屉按钮_vue 抽屉

vue 抽屉

需求背景

需要实现一个伸缩抽屉的按钮展示,且字体需要出现渐近效果

解决效果

vue3实现渐近伸缩抽屉按钮

index.vue

<!--/**
   * @author: liuk
   * @date: 2023/8/21
   * @describe: 抽屉渐近显隐按钮
   * @email:1229223630@qq.com
  */-->
<template>
  <div class="building-floor-menu">
    <div :class="['building-floor-menu-item',item.select?'select':'']" v-for="item in setData" :key="item.name"
         @mouseenter="menuItemClick(item)" @mouseleave="item.select = false">
      <div class="inner-box">
        <div class="real-box">
          <div class="name">
            <span class="tit">{{ item.name }}</span>
            <span class="pos">{{ item.pos }}</span>
          </div>
          <div class="con">
            <div class="con-list">
              <p>
                <span class="temperature">{{ item.tem1 }}</span>°C
              </p>
              <span class="average">平均室温</span>
            </div>
            <div class="con-list">
              <p>
                <span class="temperature">{{ item.tem2 }}</span></p>
              <span class="average">过冷住户</span>
            </div>
            <div class="con-list">
              <p>
                <span class="temperature">{{ item.tem3 }}</span></p>
              <span class="average">过热住户</span>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script lang="ts" setup>
import {ref} from "vue";

const setData = ref([
  {
    name: '高区组名称',
    pos: "16F~22F",
    tem1: "20.1",
    tem2: 2,
    tem3: 3,
  }, {
    name: '中区组名称',
    pos: "16F~22F",
    tem1: "24.4",
    tem2: 2,
    tem3: 3,
  }, {
    name: '低区组名称',
    pos: "16F~22F",
    tem1: "23.7",
    tem2: 2,
    tem3: 3,
  },
])
const menuItemClick = (item) => {
  setData.value.forEach((x: any) => x.select = false)
  item.select = true
}
</script>
<style lang="scss" scoped>
.building-floor-menu {
  position: fixed;
  bottom: 30px;
  right: 700px;
  display: flex;

  .building-floor-menu-item {
    display: flex;
    flex-direction: column;
    width: 112px;
    height: 112px;
    padding: 12px;
    border: 1px solid transparent;
    background: rgba(38, 38, 38, 0.8);
    box-shadow: -10px 0px 22px 0px rgba(0, 0, 0, 0.22);
    border-radius: 4px;
    box-sizing: border-box;
    margin-right: 10px;
    user-select: none;
    transition: all 0.5s ease-in-out .3s;

    &.select {
      width: 250px;
      border: 1px solid #fff;

      .inner-box {
        width: 250px;
      }
    }

    .inner-box {
      width: 75px;
      overflow: hidden;
      transition: all 0.5s ease-in-out .3s;

      .real-box {
        width: 225px;

        .name {
          display: flex;
          justify-content: space-between;
          flex-wrap: nowrap;
          overflow: hidden;

          .tit {
            font-size: 14px;
            color: #FFFFFF;
            letter-spacing: 0;
            font-weight: 500;
          }

          .pos {
            font-size: 12px;
            color: #CCCCCC;
            letter-spacing: 0;
            font-weight: 400;
          }
        }

        .con {
          display: flex;
          justify-content: space-between;

          .con-list {
            width: 65px;
            height: 68px;
            margin-right: 13px;

            p {
              margin: 15px 0 5px;

              .temperature {
                font-size: 24px;
                color: #FFFFFF;
                letter-spacing: 0;
                line-height: 16px;
                font-weight: 400;
              }

              span {
                font-size: 12px;
                color: #CACACA;
                letter-spacing: 0;
                font-weight: 200;
              }
            }

            .average {
              opacity: 0.5;
              font-size: 12px;
              color: #FFFFFF;
              letter-spacing: 0;
              line-height: 16px;
              font-weight: 400;
            }
          }
        }
      }
    }
  }
}
</style>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • 136
  • 137
  • 138
  • 139
  • 140
  • 141
  • 142
  • 143
  • 144
  • 145
  • 146
  • 147
  • 148
  • 149
  • 150
  • 151
  • 152
  • 153
  • 154
  • 155
  • 156
  • 157
  • 158
  • 159
  • 160
  • 161
  • 162
  • 163
  • 164
  • 165
  • 166
  • 167
  • 168
  • 169
  • 170
  • 171
  • 172
  • 173
  • 174
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/blog/article/detail/43216
推荐阅读
  • axios可以在浏览器和node里面用原生的问题:无法在node里使用,fetch是在浏览器里使用的。(但是原生可以帮助我们理解。_vue3axiosvue3axios文章目录求一键三连前言认识axios使用Axios常见请求演示配置选项b... [详细]

  • 想象一下我们有一个非常耗性能的计算属性list,需要循环一个巨大的数组并做许多计算逻辑,并且可能也有其他计算属性依赖于list。计算属性值会基于其响应式依赖被缓存,一个计算属性仅会在其响应式依赖更新时才重新计算。一个计算属性的声明中描述的是... [详细]

  • 在项目中多处使用到表格组件,所以进行了一个基础封装,主要是通过antdvue中表格slots配置项,通过配合插槽来进行封装自定义表格;vue3.2二次封装antdvueTable组件,原有参数属性不变vue3.2中<scri... [详细]

  • 在Vue3中,watchwatchEffect是两个非常重要的响应式API。它们可以用于监听数据的变化,并在数据变化时执行相应的操作。本文将详细介绍watchwatchEffect的用法及示例,并对它们进行总结。Vue3watch与wa... [详细]

  • Teleport的灵活性使得我们能够将组件的内容渲染到任何位置。无论是在同一个组件内部还是在不同的组件之间,我们都可以通过Teleport将内容渲染到所需的目标元素中。这使得我们能够更好地控制组件的布局和样式,并实现一些复杂的交互效果。Vu... [详细]

  • vue3.0 amis 低代码框架_amis vue3
    amis是百度开源的一个低代码前端框架,它使用JSON配置来生成页面,可以减少页面开发工作量,极大提升效率。_amisvue3amisvue3amisamis是百度开源的一个低代码前端框架,它使用JSON配置来生成页面,可以减少页面开发工作... [详细]

  • 此处需要关闭element-plus的自动上传,:auto-upload=“false”语法:URL.createObjectURL(…)创建本地预览的地址,来预览。官网地址:https://vueup.github.io/vue-quil... [详细]

相关标签
  

闽ICP备14008679号