vue elementn-ui 动态导航栏展示数据

发布时间:2024-03-07 12:25:06 浏览量:162次

在element-ui的网址
http://element-cn.eleme.io/#/zh-CN/component/layout中只有写死的数据,没有同数据库结合

展示效果如下:

导航栏展示

数据需要自己在后台进行获取,封装.类似如下:

后台获取封装数据

<!--create by jyhong-->
<!--一级菜单-->
<template v-for="(temp,index) in test">
<template v-if="!temp.hasChild">
<el-menu-item :index="temp.id" :class="temp.className"><a href="javascript:void(0);" @click="changeIFSrc(temp.index)">{{temp.label}}</a></el-menu-item>
</template>
<template v-else>
<!--二级菜单-->
<el-submenu :index="temp.id">
<template slot="title">{{temp.label}}</template>
<template v-for="(temp2,index2) in temp.child">
<el-menu-item v-if="!temp2.hasChild" :index="temp2.id" :class="temp2.className"><a href="javascript:void(0);" @click="changeIFSrc(temp.index)">{{temp2.label}}</a></el-menu-item>
<el-submenu v-else :index="temp2.id">
<template slot="title">{{temp2.label}}</template>
<!--三级菜单-->
<el-menu-item v-for="(sontemp,index2) in temp2.child" :index="sontemp.id"><a href="javascript:void(0);" @click="changeIFSrc(temp.index)">{{sontemp.label}}</a></el-menu-item>
</el-submenu>
</template>
</el-submenu>
</template>
</template>

热门课程推荐

热门资讯

请绑定手机号

x

同学您好!

您已成功报名0元试学活动,老师会在第一时间与您取得联系,请保持电话畅通!
确定