app.js 1.2 KB

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