您的位置:首页 > 教育 > 培训 > 响应式网页设计与制作_商城网站设计需要哪些技术_app推广赚佣金_优化大师最新版本

响应式网页设计与制作_商城网站设计需要哪些技术_app推广赚佣金_优化大师最新版本

2025/3/11 7:26:37 来源:https://blog.csdn.net/liuyang___/article/details/146067495  浏览:    关键词:响应式网页设计与制作_商城网站设计需要哪些技术_app推广赚佣金_优化大师最新版本
响应式网页设计与制作_商城网站设计需要哪些技术_app推广赚佣金_优化大师最新版本

这个效果涉及到一个属性,就是default-active=""

当且仅当标签是el-menu-item的时候,index才会生效,也就是说二级标签才会生效,比如el-submenu就不能生效

 <el-aside style="width: 200px;min-height: 100vh;"><divstyle="height: 60px;width: 200px;display: flex;align-items: center;justify-content: center;background-color: #ccc;color: white;">logo</div><el-menu style="border: none;" default-active="/"><el-menu-item index="/"><template slot="title"><i class="el-icon-house"></i><span>系统首页</span></template></el-menu-item><el-menu-item>系统首页</el-menu-item><el-menu-item>系统首页</el-menu-item><el-submenu><template slot="title"><i class="el-icon-menu"></i><span>信息管理</span></template><el-menu-item>系统首页</el-menu-item><el-menu-item>系统首页</el-menu-item></el-submenu></el-menu></el-aside>

当然此时我们还是死的,只能让第一个变成高亮,那变活如何处理呢!?所以就要用到绑定属性了

        <el-menu style="border: none;" :default-active="$route.path">

更改这样代码,加上 :default-active="$route.path",@route.path是当前浏览器正在访问的路由

我们现在可以进行高亮了,但是不能点击啊!怎么做到点击高亮呢?

在添加一个属性,router,这样就可以绑定路由了,也就能做到,点哪个路由就跳转到哪个路由了!

 <el-aside style="width: 200px;min-height: 100vh;"><divstyle="height: 60px;width: 200px;display: flex;align-items: center;justify-content: center;background-color: #ccc;color: white;">logo</div><el-menu style="border: none;" router :default-active="$route.path"><el-menu-item index="/"><template slot="title"><i class="el-icon-house"></i><span>系统首页</span></template></el-menu-item><el-menu-item index="/element">element页面</el-menu-item><el-menu-item>系统首页</el-menu-item><el-submenu><template slot="title"><i class="el-icon-menu"></i><span>信息管理</span></template><el-menu-item>系统首页</el-menu-item><el-menu-item>系统首页</el-menu-item></el-submenu></el-menu></el-aside>

我们在补充几个属性,

 <el-menu text-color="rgba(255,255,255,0.65)" active-text-color="#fff" background-color="#001529" style="border: none;"router :default-active="$route.path"><el-menu-item index="/"><template slot="title"><i class="el-icon-house"></i><span>系统首页</span></template></el-menu-item><el-menu-item index="/element">element页面</el-menu-item><el-menu-item>系统首页</el-menu-item><el-submenu><template slot="title"><i class="el-icon-menu"></i><span>信息管理</span></template><el-menu-item>系统首页</el-menu-item><el-menu-item>系统首页</el-menu-item></el-submenu></el-menu>

 text-color="rgba(255,255,255,0.65)":这个就是字体颜色

active-text-color="#fff"这个就是高亮之后的颜色

background-color="#001529"背景颜色

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com