|
@@ -0,0 +1,93 @@
|
|
|
|
+<template>
|
|
|
|
+ <div class="">
|
|
|
|
+ <div class="logo" />
|
|
|
|
+ <a-menu
|
|
|
|
+ theme="dark"
|
|
|
|
+ mode="inline"
|
|
|
|
+ :default-selected-keys="[activeMenu]"
|
|
|
|
+ :default-open-keys="['/user']"
|
|
|
|
+ >
|
|
|
|
+ <template v-for="route in routes">
|
|
|
|
+ <a-menu-item
|
|
|
|
+ v-if="!route.children"
|
|
|
|
+ :key="route.path"
|
|
|
|
+ @click="handleMenuRouterFun(route)"
|
|
|
|
+ >
|
|
|
|
+ <a-icon :type="route.meta.icon" />
|
|
|
|
+ <span>{{ route.meta.title }}</span>
|
|
|
|
+ </a-menu-item>
|
|
|
|
+ <a-sub-menu v-else :key="route.path">
|
|
|
|
+ <span slot="title">
|
|
|
|
+ <a-icon :type="route.meta.icon" />
|
|
|
|
+ <span>{{ route.meta.title }}</span>
|
|
|
|
+ </span>
|
|
|
|
+ <a-menu-item
|
|
|
|
+ v-for="routeChild in route.children"
|
|
|
|
+ :key="routeChild.path"
|
|
|
|
+ @click="handleMenuRouterFun(routeChild)"
|
|
|
|
+ >
|
|
|
|
+ <a-icon :type="routeChild.meta.icon" />
|
|
|
|
+ <span>{{ routeChild.meta.title }}</span>
|
|
|
|
+ </a-menu-item>
|
|
|
|
+ </a-sub-menu>
|
|
|
|
+ </template>
|
|
|
|
+ </a-menu>
|
|
|
|
+ </div>
|
|
|
|
+</template>
|
|
|
|
+
|
|
|
|
+<script>
|
|
|
|
+import { mapGetters } from 'vuex';
|
|
|
|
+export default {
|
|
|
|
+ props: {},
|
|
|
|
+ components: {},
|
|
|
|
+ data() {
|
|
|
|
+ return {
|
|
|
|
+ menuList: [],
|
|
|
|
+ rootSubmenuKeys: ['sub1', 'sub2', 'sub4'],
|
|
|
|
+ openKeys: ['sub1'],
|
|
|
|
+ };
|
|
|
|
+ },
|
|
|
|
+ created() {
|
|
|
|
+ this.initDataFun(); //初始化数据
|
|
|
|
+ },
|
|
|
|
+ mounted() {
|
|
|
|
+ console.log(this.routes);
|
|
|
|
+ },
|
|
|
|
+ beforeDestroy() {},
|
|
|
|
+ watch: {},
|
|
|
|
+ computed: {
|
|
|
|
+ ...mapGetters(['routes', 'sidebar']),
|
|
|
|
+ activeMenu() {
|
|
|
|
+ const route = this.$route;
|
|
|
|
+ const { meta, path } = route;
|
|
|
|
+ // if set path, the sidebar will highlight the path you set
|
|
|
|
+ if (meta.activeMenu) {
|
|
|
|
+ return meta.activeMenu;
|
|
|
|
+ }
|
|
|
|
+ console.log(meta, path);
|
|
|
|
+ return path;
|
|
|
|
+ },
|
|
|
|
+ },
|
|
|
|
+ methods: {
|
|
|
|
+ //初始化数据
|
|
|
|
+ initDataFun() {
|
|
|
|
+ this.menuList = [{}];
|
|
|
|
+ },
|
|
|
|
+ // 操作:点击了某个路由菜单
|
|
|
|
+ handleMenuRouterFun(item) {
|
|
|
|
+ console.log(item);
|
|
|
|
+ this.$router.push({ path: item.path });
|
|
|
|
+ },
|
|
|
|
+ },
|
|
|
|
+};
|
|
|
|
+</script>
|
|
|
|
+
|
|
|
|
+<style lang="less"></style>
|
|
|
|
+
|
|
|
|
+<style lang="less" scoped>
|
|
|
|
+.logo {
|
|
|
|
+ height: 32px;
|
|
|
|
+ background: rgba(255, 255, 255, 0.2);
|
|
|
|
+ margin: 16px;
|
|
|
|
+}
|
|
|
|
+</style>
|