Sidebar.vue 3.9 KB
Newer Older
L
lin-xin 已提交
1 2
<template>
    <div class="sidebar">
L
lin-xin 已提交
3 4
        <el-menu :default-active="onRoutes" class="el-menu-vertical-demo" background-color="#324157"
            text-color="#bfcbd9" active-text-color="#20a0ff" unique-opened router>
L
lin-xin 已提交
5 6
            <template v-for="item in items">
                <template v-if="item.subs">
L
lin-xin 已提交
7 8 9 10 11 12
                    <el-submenu :index="item.index" :key="item.index">
                        <template slot="title">
                            <i :class="item.icon"></i>{{ item.title }}
                        </template>
                        <el-menu-item v-for="(subItem,i) in item.subs" :key="i" :index="subItem.index">
                            {{ subItem.title }}
L
lin-xin 已提交
13 14 15 16
                        </el-menu-item>
                    </el-submenu>
                </template>
                <template v-else>
L
lin-xin 已提交
17
                    <el-menu-item :index="item.index" :key="item.index">
L
lin-xin 已提交
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
                        <i :class="item.icon"></i>{{ item.title }}
                    </el-menu-item>
                </template>
            </template>
        </el-menu>
    </div>
</template>

<script>
    export default {
        data() {
            return {
                items: [
                    {
                        icon: 'el-icon-setting',
                        index: 'readme',
L
lin-xin 已提交
34
                        title: '自述文件'
L
lin-xin 已提交
35 36 37 38
                    },
                    {
                        icon: 'el-icon-menu',
                        index: '2',
L
lin-xin 已提交
39
                        title: '常用表格',
L
lin-xin 已提交
40 41 42 43 44 45 46
                        subs: [
                            {
                                index: 'basetable',
                                title: '基础表格'
                            },
                            {
                                index: 'vuetable',
L
lin-xin 已提交
47
                                title: 'datasource表格'
L
lin-xin 已提交
48 49 50 51 52 53
                            }
                        ]
                    },
                    {
                        icon: 'el-icon-date',
                        index: '3',
L
lin-xin 已提交
54
                        title: '表单相关',
L
lin-xin 已提交
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
                        subs: [
                            {
                                index: 'baseform',
                                title: '基本表单'
                            },
                            {
                                index: 'vueeditor',
                                title: '编辑器'
                            },
                            {
                                index: 'markdown',
                                title: 'markdown'
                            },
                            {
                                index: 'upload',
                                title: '文件上传'
                            }
                        ]
                    },
                    {
                        icon: 'el-icon-star-on',
                        index: 'basecharts',
L
lin-xin 已提交
77
                        title: 'schart图表'
L
lin-xin 已提交
78
                    },
L
lin-xin 已提交
79 80 81 82 83
                    // {
                    //     icon: 'el-icon-edit',
                    //     index: 'drag',
                    //     title: '拖拽列表'
                    // },
L
lin-xin 已提交
84
                    {
L
lin-xin 已提交
85
                        icon: 'el-icon-warning',
L
lin-xin 已提交
86
                        index: 'permission',
L
lin-xin 已提交
87
                        title: '权限测试'
L
lin-xin 已提交
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112
                    }
                ]
            }
        },
        computed:{
            onRoutes(){
                return this.$route.path.replace('/','');
            }
        }
    }
</script>

<style scoped>
    .sidebar{
        display: block;
        position: absolute;
        width: 250px;
        left: 0;
        top: 70px;
        bottom:0;
        background: #2E363F;
    }
    .sidebar > ul {
        height:100%;
    }
L
lin-xin 已提交
113 114 115
    .sidebar i{
        margin-top: -4px;
    }
L
lin-xin 已提交
116
</style>