element-admin
表单 Layout
新建 src\views\list-and-form\form.vue
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
| <template> <div class="app-wrapper-form"> <section class="app-main"> <transition name="fade-transform" mode="out-in"> <router-view :key="key" /> </transition> </section> </div> </template>
<script> export default { name: "FormLayout", computed: { key() { return this.$route.path; }, }, }; </script>
<style scoped> .app-main { /*50 = navbar */ min-height: 100vh; /* calc(100vh - 50px); */ width: 100%; position: relative; overflow: hidden; background-color: #e7e8eb; } .fixed-header + .app-main { padding-top: 50px; } </style>
<style lang="scss"> // fix css style bug in open el-dialog .el-popup-parent--hidden { .fixed-header { padding-right: 15px; } } </style>
|
配置路由
修改 src\router\index.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
|
{ path: '/list-and-form', component: Layout, redirect: '/list-and-form/list', name: 'ListAndForm', meta: { title: '列表和表单', icon: 'table' }, children: [ { path: 'list', name: 'ListAndForm_List', component: () => import('@/views/list-and-form/list'), meta: { title: '列表', icon: 'table' } }, { path: 'list1', name: 'ListAndForm_List1', component: () => import('@/views/list-and-form/list1'), meta: { title: '列表1', icon: 'table' } } ] },
{ hidden: true, path: '/hidden/form', component: FormLayout, name: 'HiddenForm', children: [ { path: '/list-and-form/form', name: 'ListAndForm_Form', component: () => import('@/views/list-and-form/form'), meta: { title: '表单', icon: 'form' } } ] },
|
提示:
1、父级路由下只有一个子级路由时,菜单只显示父级,不显示子级
2、顶级路由设置 Layout 后,所有的子级都会嵌套进去