main.js 783 B

12345678910111213141516171819202122232425262728293031323334353637
  1. import Vue from 'vue';
  2. import iView from 'iview';
  3. import VueRouter from 'vue-router';
  4. import Routers from './router';
  5. import Util from './libs/util';
  6. import App from './app.vue';
  7. import 'iview/dist/styles/iview.css';
  8. import axios from 'axios';
  9. Vue.prototype.$http = axios;
  10. axios.defaults.baseURL = 'http://127.0.0.1:8100';
  11. Vue.use(VueRouter);
  12. Vue.use(iView);
  13. // 路由配置
  14. const RouterConfig = {
  15. mode: 'history',
  16. routes: Routers
  17. };
  18. const router = new VueRouter(RouterConfig);
  19. router.beforeEach((to, from, next) => {
  20. iView.LoadingBar.start();
  21. Util.title(to.meta.title);
  22. next();
  23. });
  24. router.afterEach((to, from, next) => {
  25. iView.LoadingBar.finish();
  26. window.scrollTo(0, 0);
  27. });
  28. new Vue({
  29. el: '#app',
  30. router: router,
  31. render: h => h(App)
  32. });