entry.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import Vue from 'vue';
  2. import entry from './app';
  3. import VueRouter from 'vue-router';
  4. import configRouter from './route.config';
  5. import Element from 'main/index.js';
  6. import 'packages/theme-default/src/index.css';
  7. import demoBlock from './components/demo-block.vue';
  8. import MainFooter from './components/footer.vue';
  9. import MainHeader from './components/header.vue';
  10. import SideNav from './components/side-nav';
  11. Vue.use(Element);
  12. Vue.use(VueRouter);
  13. Vue.component('demo-block', demoBlock);
  14. Vue.component('main-footer', MainFooter);
  15. Vue.component('main-header', MainHeader);
  16. Vue.component('side-nav', SideNav);
  17. const scrollBehavior = (to, from, savedPosition) => {
  18. if (savedPosition) {
  19. // savedPosition is only available for popstate navigations.
  20. return savedPosition;
  21. } else {
  22. // new navigation.
  23. // scroll to anchor
  24. if (to.hash) {
  25. return { anchor: true };
  26. }
  27. // explicitly control scroll position
  28. // check if any matched route config has meta that requires scrolling to top
  29. if (to.matched.some(m => m.meta.scrollToTop)) {
  30. return { x: 0, y: 0 };
  31. }
  32. }
  33. };
  34. const router = new VueRouter({
  35. mode: 'history',
  36. base: __dirname,
  37. scrollBehavior,
  38. routes: configRouter
  39. });
  40. new Vue({ // eslint-disable-line
  41. render: h => h(entry),
  42. router
  43. }).$mount('#app');