add footer-nav

pull/28/head
Leopoldthecoder 2016-09-07 14:18:17 +08:00
parent 267f3c20bc
commit 74abc40bf3
7 changed files with 115 additions and 14 deletions

View File

@ -0,0 +1,105 @@
<template>
<div class="footer-nav">
<span
v-if="leftNav"
class="footer-nav-link footer-nav-left"
@click="handleNavClick('prev')">
<i class="el-icon-arrow-left"></i>
{{ leftNav.title || leftNav.name }}
</span>
<span
v-if="rightNav"
class="footer-nav-link footer-nav-right"
@click="handleNavClick('next')">
{{ rightNav.title || rightNav.name }}
<i class="el-icon-arrow-right"></i>
</span>
</div>
</template>
<style>
.footer-nav {
padding: 24px;
color: #99a9bf;
font-size: 14px;
&::after {
content: '';
display: block;
clear: both;
}
& i {
color: #d9def1;
vertical-align: baseline;
}
}
.footer-nav-link {
cursor: pointer;
&:hover {
color: #5e6d82;
& i {
color: #5e6d82;
}
}
}
.footer-nav-left {
float: left;
}
.footer-nav-right {
float: right;
}
</style>
<script>
import navConfig from '../nav.config.json';
export default {
data() {
return {
currentComponent: null,
nav: [],
currentIndex: -1,
leftNav: null,
rightNav: null
};
},
watch: {
'$route.path'() {
this.updateNav();
}
},
methods: {
updateNav() {
this.currentComponent = '/' + this.$route.path.split('/')[2];
for (let i = 0, len = this.nav.length; i < len; i++) {
if (this.nav[i].path === this.currentComponent) {
this.currentIndex = i;
break;
}
}
this.leftNav = this.nav[this.currentIndex - 1];
this.rightNav = this.nav[this.currentIndex + 1];
},
handleNavClick(direction) {
this.$router.push(`/component${ direction === 'prev' ? this.leftNav.path : this.rightNav.path }`);
}
},
created() {
navConfig[0].groups.map(group => group.list).forEach(list => {
this.nav = this.nav.concat(list);
});
this.nav = this.nav.concat(navConfig[1].children);
this.updateNav();
}
}
</script>

View File

@ -14,7 +14,7 @@
</el-pagination> </el-pagination>
</div> </div>
<div class="block"> <div class="block">
<span class="demonstration">大于7页时的效果</span> <span class="demonstration">大于 7 页时的效果</span>
<el-pagination <el-pagination
layout="prev, pager, next" layout="prev, pager, next"
:total="1000"> :total="1000">
@ -129,7 +129,7 @@
} }
</script> </script>
<style> <style>
.demo-pagination .first { .demo-pagination .source.first {
padding: 0; padding: 0;
display: flex; display: flex;
} }
@ -152,7 +152,7 @@
margin-bottom: 20px; margin-bottom: 20px;
} }
.demo-pagination .last { .demo-pagination .source.last {
padding: 0; padding: 0;
} }
@ -174,7 +174,7 @@
.demo-pagination .last .demonstration + .el-pagination { .demo-pagination .last .demonstration + .el-pagination {
float: right; float: right;
width: 70%; width: 70%;
margin-right: 20px; margin: 5px 20px 0 0;
} }
</style> </style>

View File

@ -8,6 +8,7 @@ import demoBlock from './components/demo-block.vue';
import MainFooter from './components/footer.vue'; import MainFooter from './components/footer.vue';
import MainHeader from './components/header.vue'; import MainHeader from './components/header.vue';
import SideNav from './components/side-nav'; import SideNav from './components/side-nav';
import FooterNav from './components/footer-nav';
Vue.use(Element); Vue.use(Element);
Vue.use(VueRouter); Vue.use(VueRouter);
@ -15,6 +16,7 @@ Vue.component('demo-block', demoBlock);
Vue.component('main-footer', MainFooter); Vue.component('main-footer', MainFooter);
Vue.component('main-header', MainHeader); Vue.component('main-header', MainHeader);
Vue.component('side-nav', SideNav); Vue.component('side-nav', SideNav);
Vue.component('footer-nav', FooterNav);
const scrollBehavior = (to, from, savedPosition) => { const scrollBehavior = (to, from, savedPosition) => {
if (savedPosition) { if (savedPosition) {

View File

@ -6,7 +6,7 @@
"list": [ "list": [
{ {
"path": "/layout", "path": "/layout",
"name": "按钮 (button)", "name": "布局 (layout)",
"title": "Layout 布局", "title": "Layout 布局",
"description": "" "description": ""
}, },

View File

@ -45,6 +45,7 @@
</el-col> </el-col>
<el-col :span="18"> <el-col :span="18">
<router-view class="content"></router-view> <router-view class="content"></router-view>
<footer-nav></footer-nav>
</el-col> </el-col>
</el-row> </el-row>
</div> </div>
@ -56,9 +57,6 @@
return { return {
navsData: navs navsData: navs
}; };
},
updated() {
console.log(this.navsData);
} }
}; };
</script> </script>

View File

@ -120,11 +120,7 @@ export default {
// 判断是否text-overflow, 如果是就显示tooltip // 判断是否text-overflow, 如果是就显示tooltip
const cellChild = getChild(event); const cellChild = getChild(event);
if (cellChild.scrollWidth > cellChild.offsetWidth) { this.tooltipDisabled = cellChild.scrollWidth <= cellChild.offsetWidth;
this.tooltipDisabled = false;
} else {
this.tooltipDisabled = true;
}
}, },
handleCellMouseLeave(event) { handleCellMouseLeave(event) {

View File

@ -108,7 +108,7 @@
} }
@e total { @e total {
margin-left: 10px; margin: 0 10px;
} }
@e rightwrapper { @e rightwrapper {