main.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. import Vue from 'vue'
  2. import App from './App.vue'
  3. import routes from './routes'
  4. import VueRouter from 'vue-router'
  5. import ViewUI from 'view-design';
  6. import Language from '../_modules/language'
  7. import '../common'
  8. Vue.use(VueRouter);
  9. Vue.use(ViewUI);
  10. Vue.use(Language);
  11. import Title from '../_components/Title.vue'
  12. Vue.component('VTitle', Title);
  13. const router = new VueRouter({routes});
  14. //进度条配置
  15. ViewUI.LoadingBar.config({
  16. color: '#3fcc25',
  17. failedColor: '#ff0000'
  18. });
  19. router.beforeEach((to, from, next) => {
  20. ViewUI.LoadingBar.start();
  21. next();
  22. });
  23. router.afterEach((to, from, next) => {
  24. ViewUI.LoadingBar.finish();
  25. });
  26. //加载函数
  27. Vue.prototype.goForward = function(location, isReplace) {
  28. if (typeof location === 'string') location = {name: location};
  29. if (isReplace === true) {
  30. this.$router.replace(location);
  31. }else{
  32. this.$router.push(location);
  33. }
  34. };
  35. //返回函数
  36. Vue.prototype.goBack = function(number) {
  37. window.history.go(typeof number==='number'?number:-1)
  38. };
  39. Vue.prototype.$A = $A;
  40. Vue.config.productionTip = false;
  41. const app = new Vue({
  42. el: '#app',
  43. router,
  44. template: '<App/>',
  45. components: { App }
  46. });
  47. $A.app = app;