赞
踩
- <template>
- <div class="app">
- <Header :isSideBarShow="isSideBarShow" @isSideBarShow="sideBarShow" />
- <div class="main">
- <SideBar :isSideBarShow="isSideBarShow" @reciveIndex="reciveIndex"></SideBar>
- <div ref="content" :style="{left: contentLeft + 'px'}" class="content">
- <!-- <keep-alive exclude="ScrollDemo">
- <components :is="pageName"></components>
- </keep-alive>-->
- <router-view></router-view>
- </div>
- </div>
- </div>
- </template>
-
- <script>
- import Header from "../../components/header/index.vue";
- import SideBar from "../../components/sideBar/index.vue";
- // 页面
-
- export default {
- name: "App",
- components: {
- Header,
- SideBar
- },
- data() {
- return {
- isShow: false,
- isSideBarShow: true // 控制侧边栏是否显示
- };
- },
- mounted() {
- window.app = this;
- },
- computed: {
- contentLeft() {
- // 控制右侧是否全屏
- return this.isSideBarShow ? 200 : 0;
- }
- },
- methods: {
- reciveIndex(componentName) {
- this.pageName = componentName;
- },
- sideBarShow() {
- this.isSideBarShow = !this.isSideBarShow;
- }
- }
- };
- </script>
-
- <style scoped>
- .app {
- position: absolute;
- left: 0;
- top: 0;
- bottom: 0;
- right: 0;
- }
- .main {
- position: absolute;
- left: 0;
- right: 0;
- top: 81px;
- bottom: 0;
- }
- .content {
- position: absolute;
- right: 0;
- top: 0px;
- bottom: 0px;
- background-color: #eee;
- padding-left: 10px;
- padding-top: 10px;
- overflow: auto;
- transition: all 0.4s;
- }
- </style>
- <template>
- <transition>
- <div v-show="isSideBarShow" class="side-bar">
- <ul>
- <li
- :class="$route.matched[1].path === item.toPath ? 'active' : ''"
- @click="handleClick(item, key)"
- v-for="(item,key) in asideData"
- :key="key"
- >
- <span>{{item.name}}</span>
- </li>
- </ul>
- </div>
- </transition>
- </template>
- <script>
- import { createAsideData } from "../../router/router.config";
-
- export default {
- data() {
- return {
- asideData: createAsideData()
- };
- },
- props: ["isSideBarShow"],
- methods: {
- handleClick(item, key) {
- this.pageIndex = key;
- this.$router.push(item.toPath);
- }
- },
- mounted() {
- window.side = this;
- }
- };
- </script>
- <style scoped>
- .side-bar {
- position: absolute;
- left: 0px;
- top: 0;
- width: 200px;
- bottom: 0;
- background-color: rgb(27, 38, 44);
- color: rgb(187, 225, 250);
- overflow-y: auto;
- }
- ul {
- padding: 0;
- cursor: pointer;
- margin: 0;
- }
- li {
- padding-left: 20px;
- list-style: none;
- line-height: 40px;
- background-color: rgb(15, 76, 117);
- margin-bottom: 1px;
- }
- li:hover,
- li.active {
- background-color: rgb(50, 130, 184);
- color: #fff;
- }
- .v-enter {
- left: -200px;
- }
- .v-enter-active {
- transition: all 0.3s;
- }
- .v-leave-active {
- left: -200px;
- transition: all 2s;
- }
- </style>
- const routerConfigAside = [
- {
- path: '',
- redirect: 'todolist'
- },
- { title: '待办事项', path: 'todolist', component: TodoList, meta: { num: 23 } },
- { title: '拖拽效果', path: 'dragtest', component: DragTest },
- { title: '简单滚动条', path: 'scrolltest', component: ScrollTest },
- { title: '滚动条案例', path: 'scrolldemo', component: ScrollDemo },
- { title: '组件通信', path: 'infotest', component: InfoTest },
- { title: '监听属性', path: 'listening', component: Listening },
- { title: '收集信息', path: 'collectionsfunctions', component: CollectionsFunctions },
- { title: '订单系统', path: 'orderos', component: OrderOs },
- { title: '动画案例', path: 'transitionTest', component: TransitionTest },
- { title: '考试-导航', path: 'navtest', component: NavTest },
- { title: '生命周期', path: 'lifeloop', component: LifeLoop },
- {
- title: '动态路由',
- path: 'moverouter',
- component: MoveRouter,
- children: [
- {
- path: '',
- redirect: 'list'
- },
- {
- name: 'list',
- path: 'list',
- alias: 'listOther',
- component: MoveRouterList
- },
- {
- name: 'detail',
- path: 'detail/:sid',
- component: MoveRouterDetail
- }
- ]
- },
- {
- title: '插槽',
- path: 'slot',
- component: VueSlot
- },
- { title: '状态管理-vuex', path: 'storemanger', component: StoreManger },
- { title: '订单系统-vuex', path: 'orderosvuex', component: OrderOsVuex },
- { title: '递归组件-tree', path: 'tree', component: Tree },
- { title: '仿照windows目录', path: 'windowsfloder', component: WidowsFloder }
- ]
- // 生成侧边栏数据
- export function createAsideData() {
- return routerConfigAside.filter(item => item.title).map(item => {
- return {
- toPath: routerConfig[2].path + '/' + item.path,
- name: item.title
- }
- })
- }
- <template>
- <div class="header">
- <h1>
- <a href="/">
- </a>
- </h1>
- <div class="controlSidebar">
- <button
- :class="[isSideBarShow ? 'hide' : 'show']"
- @click="btnHandleClick"
- >{{isSideBarShow ? '隐藏' : '显示'}}</button>
- </div>
- <div class="weektwo">
- <router-link to="/weektwo">查看周考二试题</router-link>
- </div>
- <div class="tool">
- <button>
- <router-link to="/login">退出</router-link>
- </button>
- </div>
- </div>
- </template>
- <script>
- export default {
- props: {
- isSideBarShow: {
- type: Boolean,
- default() {
- return true;
- }
- }
- },
- methods: {
- btnHandleClick() {
- this.$emit("isSideBarShow");
- }
- }
- };
- </script>
- <style scoped>
- h1 {
- margin: 0;
- padding: 0;
- float: left;
- height: 100%;
- padding-left: 10px;
- }
- h1 img {
- display: inline-block;
- position: relative;
- top: 10px;
- }
-
- .header {
- height: 80px;
- border-bottom: 1px solid rgb(27, 38, 44);
- background-color: #fff;
- }
- .controlSidebar {
- float: left;
- height: 100%;
- padding-left: 20px;
- position: relative;
- width: 100px;
- }
- .controlSidebar button {
- position: absolute;
- top: 50%;
- min-width: 75px;
- transform: translateY(-50%);
- outline: none;
- border: 1px solid #ccc;
- padding: 5px 20px;
- border-radius: 10px;
- background: transparent;
- cursor: pointer;
- }
- .controlSidebar button.show {
- background: #011801;
- color: #fff;
- }
- .tool {
- float: right;
- height: 100%;
- padding-right: 100px;
- position: relative;
- }
- .tool button {
- position: absolute;
- top: 50%;
- transform: translateY(-50%);
- border: 1px solid #ccc;
- outline: none;
- background-color: transparent;
- padding: 10px 20px;
- border-radius: 8px;
- }
- .weektwo {
- float: left;
- line-height: 80px;
- }
- </style>
无语非说我质量有问题,凑个字数……
无语非说我质量有问题,凑个字数……
无语非说我质量有问题,凑个字数……
无语非说我质量有问题,凑个字数……
无语非说我质量有问题,凑个字数……
无语非说我质量有问题,凑个字数……
无语非说我质量有问题,凑个字数……
无语非说我质量有问题,凑个字数……
无语非说我质量有问题,凑个字数……
无语非说我质量有问题,凑个字数……
无语非说我质量有问题,凑个字数……
无语非说我质量有问题,凑个字数……
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。