mirror of
https://gitee.com/ElemeFE/element.git
synced 2024-11-30 03:07:36 +08:00
use hash
This commit is contained in:
parent
65d6938ddf
commit
f7cc340f3c
@ -81,6 +81,11 @@
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'app'
|
||||
name: 'app',
|
||||
created() {
|
||||
window.addEventListener('hashchange', () => {
|
||||
document.body.scrollTop = 0;
|
||||
});
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
@ -72,10 +72,12 @@
|
||||
line-height: 120px;
|
||||
|
||||
.footer-popover {
|
||||
.el-popover {
|
||||
padding: 0;
|
||||
min-width: 120px;
|
||||
line-height: normal;
|
||||
box-shadow: 0 0 11px 0 rgba(174, 187, 211, 0.24);
|
||||
}
|
||||
|
||||
.footer-popover-title {
|
||||
border-bottom: solid 1px #eaeefb;
|
||||
|
@ -18,28 +18,9 @@ Vue.component('main-header', MainHeader);
|
||||
Vue.component('side-nav', SideNav);
|
||||
Vue.component('footer-nav', FooterNav);
|
||||
|
||||
const scrollBehavior = (to, from, savedPosition) => {
|
||||
if (savedPosition) {
|
||||
// savedPosition is only available for popstate navigations.
|
||||
return savedPosition;
|
||||
} else {
|
||||
// new navigation.
|
||||
// scroll to anchor
|
||||
if (to.hash) {
|
||||
return { anchor: true };
|
||||
}
|
||||
// explicitly control scroll position
|
||||
// check if any matched route config has meta that requires scrolling to top
|
||||
if (to.matched.some(m => m.meta.scrollToTop)) {
|
||||
return { x: 0, y: 0 };
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const router = new VueRouter({
|
||||
mode: 'history',
|
||||
mode: 'hash',
|
||||
base: __dirname,
|
||||
scrollBehavior,
|
||||
routes: configRouter
|
||||
});
|
||||
|
||||
|
@ -4,8 +4,7 @@ const registerRoute = (config) => {
|
||||
let route = [{
|
||||
path: '/component',
|
||||
component: require('./pages/component.vue'),
|
||||
children: [],
|
||||
scrollToTop: true
|
||||
children: []
|
||||
}];
|
||||
function addRoute(page) {
|
||||
const component = require(`./docs${page.path}.md`);
|
||||
@ -14,8 +13,7 @@ const registerRoute = (config) => {
|
||||
path: page.path.slice(1),
|
||||
meta: {
|
||||
title: page.title || page.name,
|
||||
description: page.description,
|
||||
scrollToTop: true
|
||||
description: page.description
|
||||
},
|
||||
component: component.default || component
|
||||
});
|
||||
@ -45,7 +43,6 @@ let guideRoute = {
|
||||
path: '/guide',
|
||||
name: '指南',
|
||||
component: require('./pages/guide.vue'),
|
||||
meta: { scrollToTop: true },
|
||||
children: [{
|
||||
path: 'design',
|
||||
name: '设计原则',
|
||||
@ -60,20 +57,17 @@ let guideRoute = {
|
||||
let resourceRoute = {
|
||||
path: '/resource',
|
||||
name: '资源',
|
||||
meta: { scrollToTop: true },
|
||||
component: require('./pages/resource.vue')
|
||||
};
|
||||
|
||||
let indexRoute = {
|
||||
path: '/',
|
||||
name: '首页',
|
||||
meta: { scrollToTop: true },
|
||||
component: require('./pages/index.vue')
|
||||
};
|
||||
|
||||
let changeLogRoute = {
|
||||
path: '/changelog',
|
||||
meta: { scrollToTop: true },
|
||||
component: require('./pages/changelog.vue')
|
||||
};
|
||||
|
||||
|
@ -63,7 +63,7 @@ export default {
|
||||
|
||||
const options = this.options;
|
||||
const popper = this.popper || this.$refs.popper;
|
||||
const reference = this.reference || this.$refs.reference || this.$slots.reference[0].elm;;
|
||||
const reference = this.reference || this.$refs.reference || this.$slots.reference[0].elm;
|
||||
|
||||
if (!popper || !reference) return;
|
||||
if (this.visibleArrow) {
|
||||
|
Loading…
Reference in New Issue
Block a user