前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >uni-app/vue 结合element ui实现菜单分类导航(类似于小米商城首页的分类导航那种)

uni-app/vue 结合element ui实现菜单分类导航(类似于小米商城首页的分类导航那种)

作者头像
代码哈士奇
发布2021-10-25 11:37:36
1.4K0
发布2021-10-25 11:37:36
举报
文章被收录于专栏:dmhsq_csdn_blogdmhsq_csdn_blog

效果如下 数据来源为uniCloud云数据库 照片来源为网络 代码来源为我的毕业设计

在这里插入图片描述
在这里插入图片描述

鼠标未放到软件上面之前

在这里插入图片描述
在这里插入图片描述

放到软件上面后 软件所在卡片 高亮显示 如果背景颜色是灰色 效果更加明显

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

使用element ui的 卡片 走马灯 弹出框 文字链接 分割线

elementui文档地址 https://element.eleme.cn/#/zh-CN/component/installation

这里的

在这里插入图片描述
在这里插入图片描述

是数据来源 自行更换即可

完整代码如下

代码语言:javascript
复制
<template>
	<div>
		<el-container>
			<el-aside width="400px" style="position: relative;top: 20px;left: 15px;height: 500px;">
				<div style="height: 500px;">
					<div v-for="(item,index) in menus" :key="index">
						<div style="width: 340px;height: 49px;margin-left: 30px;line-height: 10px;"
							@mouseover="showMsg(item.menu_two)" @mouseleave="unShow">
							<el-card shadow="hover" style="width: 340px;height: 49px;line-height: 10px;">
								{{item.type}}
							</el-card>
						</div>
						<div style="margin-top: 5px;"></div>
					</div>
				</div>
			</el-aside>
			<el-main>
				<div v-show="isShow" class="show-menu" @mouseover="isShow_o=true" @mouseleave="unShows()">
					<span>⁣⁣⁣⁣ ⁣⁣⁣⁣ </span>
					<div v-for="(item,index) in meunItems" :key="index">
						<el-divider content-position="left">{{item.type}}</el-divider>
						<div style="margin-left: 20px;">
							<el-popover v-for="(items,indexs) in item.items" :key="indexs" placement="top-start"
								:title="items.name" width="200" trigger="hover" :content="items.msg" >
									<el-link slot="reference" :underline="false" style="font-size: 20px;">{{items.name}}
										<el-divider v-if="indexs!=item.items.length-1" direction="vertical"></el-divider>
									</el-link>
							</el-popover>
						</div>
					</div>
				</div>
				<el-carousel height="500px" v-show="!isShow">
					<el-carousel-item v-for="(item,index) in carousels" :key="index">
						<el-image :src="item.url" style="width: 100%;height: 500px;"></el-image>
						<!-- <h3 class="small">{{ item }}</h3> -->
					</el-carousel-item>
				</el-carousel>
			</el-main>
		</el-container>
	</div>
</template>

<script>
	export default {
		name: 'homeMsg',
		data() {
			return {
				carousels: [],
				isShow: false,
				menus: [],
				meunItems: [],
				isShow_o: false,
				timer_a: "",
				timer_b: ""
			}
		},
		mounted() {
			this.getMenu()
			this.getCarousel()
		},
		methods: {
			showMsg(item) {
				this.isShow = true;
				this.meunItems = item
				clearTimeout(this.timer_a)
				clearTimeout(this.timer_b)
			},
			unShow() {
				this.timer_b = setTimeout(() => {
					if (!this.isShow_o) {
						this.isShow = false
					}
				}, 1000)
			},
			unShows() {
				this.isShow_o = false;
				this.timer_a = setTimeout(() => {
					this.isShow = false
				}, 1000)
			},
			getMenu() {
				const getMenus = uniCloud.database().collection("home-menu-a");
				getMenus.get().then(res => {
					this.menus = res.result.data;
				}).catch((err) => {
					console.log(err.code); // 打印错误码
					console.log(err.message); // 打印错误内容
				})
			},
			getCarousel() {
				const carousel = uniCloud.database().collection("static");
				carousel.where({
					type: "homeCarousel"
				}).get().then(res => {
					this.carousels = res.result.data
					console.log(this.carousels)
				}).catch((err) => {
					console.log(err.code); // 打印错误码
					console.log(err.message); // 打印错误内容
				})
			}
		}
	}
</script>

<style>
	.el-carousel__item h3 {
		color: #475669;
		font-size: 14px;
		opacity: 0.75;
		line-height: 150px;
		margin: 0;
	}

	.el-carousel__item:nth-child(2n) {
		background-color: #99a9bf;
	}

	.el-carousel__item:nth-child(2n+1) {
		background-color: #d3dce6;
	}

	.show-menu {
		width: 100%;
		height: 500px;
		background-color: #ffffff;
		box-shadow: darkgrey 3px 3px 10px 5px;
	}
</style>
本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2021-03-19 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
相关产品与服务
云数据库 MySQL
腾讯云数据库 MySQL(TencentDB for MySQL)为用户提供安全可靠,性能卓越、易于维护的企业级云数据库服务。其具备6大企业级特性,包括企业级定制内核、企业级高可用、企业级高可靠、企业级安全、企业级扩展以及企业级智能运维。通过使用腾讯云数据库 MySQL,可实现分钟级别的数据库部署、弹性扩展以及全自动化的运维管理,不仅经济实惠,而且稳定可靠,易于运维。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档