ELEMENT-PLUES如何设计二级高亮样式,文字如何呈现高亮效果,如果字体出现不对齐的情况,侧边栏icon如何调位置,目录如何折叠,如何延迟动画播放,如何添加阴影,如何添加logo,在行内样式写宽

217 篇文章 0 订阅
本文详细介绍了如何在Vue项目中使用ElementUI的el-menu组件实现菜单高亮效果、二级标题样式调整、折叠功能以及设置logo和aside宽度。
摘要由CSDN通过智能技术生成

参考资料:

【带小白做毕设】6. Vue管理系统速成_哔哩哔哩_bilibili

设置高亮的样式写法是这样写的:

<template>
    <div>
        <el-container>
            <el-aside style="width: 200px;min-height: 100vh;background-color:#001529">
                <div style="height: 60px; color: white; display: flex; align-items: center; justify-content: center;">
                    logo
                </div>
                <el-menu style="border:none" background-color="#001529" text-color="rgba(255,255,255,0.65)"
                    default-active="$router.path">
                    <el-menu-item index="/">
                        <template #title>
                            <el-icon>
                                <House />
                            </el-icon>
                            <span>系统首页</span>
                        </template>
                    </el-menu-item>
                    <el-menu-item>系统首页</el-menu-item>
                    <el-menu-item>系统首页</el-menu-item>
                    <el-sub-menu index="1-4">
                        <template #title>
                            <el-icon>
                                <Menu />
                            </el-icon>
                            <span>信息管理</span>
                        </template>
                        <el-menu-item index="1-4-1">用户信息</el-menu-item>
                    </el-sub-menu>
                </el-menu>
            </el-aside>

        </el-container>
    </div>
</template>
<style scoped>
.el-menu--inline .el-menu-item {
    background-color: #000c17 !important;
}
</style>

如何设置高亮效果

样式写成这样就行

.el-menu-item:hover {
    color: #fff;
}

如果二级标题和图标也想要发生改变,添加这段代码就行了

.el-menu-item:hover,
.el-sub-menu__title:hover span {
    color: #fff !important;
}

.el-sub-menu__title:hover i {
    color: #fff !important;
}

如果二级标题想要点击之后改变颜色,填这种样式就好了

.el-menu-item.is-active {
    background-color: #40a9ff !important;
    color: #fff;
    border-radius: 5px !important;
}

如果要修正长度

用这个代码就行

.el-menu-item {
    height: 40px !important;
    line-height: 40px !important;
}

.el-submenu__title {
    height: 40px !important;
    line-height: 40px !important;
}

如果出现不对齐的情况

设置图标位置,点击三角符号

折叠水平菜单,用collapse

在el-menu中添加isCollapse,同时在data中定义字符串

这里:collapse=xxx要设置,data中也要设置

<el-menu :collapse="isCollapse" style="border:none" background-color="#001529"
                    text-color="rgba(255,255,255,0.65)" default-active="$router.path">
 </el-menu>
<script lang="ts">
export default {
    name: 'HomeView',
    data() {
        return {
            isCollapse: true
        }
    }
}
</script>

写成这样就出现了折叠效果的初步形状了 

这里width不能写死,在el-aside中添加 :width="asideWidth"

<el-aside :width="asideWidth" style="min-height: 100vh;background-color:#001529">
<script lang="ts">
export default {
    name: 'HomeView',
    data() {
        return {
            isCollapse: true,
            asideWidth: '200px'
        }
    }
}
</script>

这里要在头部添加一个标签

头部要有一个icon

绑定事件,@click="handleCollapse"

 改成

.el-aside {

        transition:width .3s;

}

.el-aside {
    transition: width .30s;
}

伸缩图标如何做,这里图标消失不见了,该怎样设置

写成这样就行了

        <el-menu-item index="/">
                        <el-icon>
                            <House />
                        </el-icon>
                        <span>系统首页</span>
                    </el-menu-item>

效果

添加阴影

在.el-aside和.el-header中添加

如何添加logo,可以利用行内样式直接填,再结合F12,设置宽度

 

 <div style="height: 60px; color: white; display: flex; align-items: center; justify-content: center;">
    <img src="@/assets/logo.png" style="width: 40px;height: 40px;">
</div>

  • 5
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
要配置 MyBatis-Plus 框架,你需要按照以下步骤进行操作: 1. 首先,确保你已经在你的项目中添加了 MyBatis 和 MyBatis-Plus 的依赖。你可以在你的项目的 pom.xml (Maven) 或者 build.gradle (Gradle) 文件中添加以下依赖: Maven: ```xml <dependency> <groupId>com.baomidou</groupId> <artifactId>mybatis-plus-boot-starter</artifactId> <version>最新版本号</version> </dependency> ``` Gradle: ```groovy implementation 'com.baomidou:mybatis-plus-boot-starter:最新版本号' ``` 请确保将 "最新版本号" 替换为你想要使用的 MyBatis-Plus 版本。 2. 接下来,在你的项目的配置文件中配置 MyBatis-Plus。如果你使用的是 Spring Boot,你可以在 application.properties 或者 application.yml 文件中添加以下配置: application.properties: ```properties # 数据库相关配置 spring.datasource.url=jdbc:mysql://localhost:3306/your_database?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai spring.datasource.username=your_username spring.datasource.password=your_password # MyBatis-Plus 配置 mybatis-plus.mapper-locations=classpath*:mapper/**/*.xml mybatis-plus.type-aliases-package=com.example.entity ``` application.yml: ```yaml # 数据库相关配置 spring: datasource: url: jdbc:mysql://localhost:3306/your_database?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai username: your_username password: your_password # MyBatis-Plus 配置 mybatis-plus: mapper-locations: classpath*:mapper/**/*.xml type-aliases-package: com.example.entity ``` 请将 "your_database" 替换为你的数据库名,"your_username" 和 "your_password" 替换为你的数据库用户名和密码。 3. 最后,你需要创建实体类和对应的 Mapper 接口。实体类用于映射数据库表,Mapper 接口用于定义数据库操作方法。你可以使用 MyBatis-Plus 提供的注解和接口来简化开发,例如 @TableName、@TableId、@Mapper 等。 这样就完成了 MyBatis-Plus 的配置和基本使用。你可以根据自己的需求进一步扩展和优化。希望对你有帮助!

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

爱你三千遍斯塔克

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

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

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

打赏作者

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

抵扣说明:

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

余额充值