main.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. // The Vue build version to load with the `import` command
  2. // (runtime-only or standalone) has been set in webpack.base.conf with an alias.
  3. import Vue from 'vue';
  4. import ElementUI from 'element-ui';
  5. import 'element-ui/lib/theme-chalk/index.css';
  6. import App from './App';
  7. // 引入路由
  8. import router from './router';
  9. // 引入状态管理
  10. import store from './vuex/store';
  11. // 引入icon
  12. // import './assets/icon/iconfont.css'
  13. import touch from 'vue-directive-touch';
  14. import axios from 'axios';
  15. Vue.prototype.$axios = axios;
  16. Vue.config.productionTip = false;
  17. // 文件上传域名
  18. // Vue.prototype.$imgUrl = "http://blue.cn1.utools.club/api1/file/uploadOne
  19. Vue.use(ElementUI);
  20. Vue.use(touch);
  21. // 创建loading
  22. Vue.prototype.openLoading = function() {
  23. const loading = this.$loading({ // 声明一个loading对象
  24. lock: true, // 是否锁屏
  25. text: '正在加载...', // 加载动画的文字
  26. spinner: 'el-icon-loading', // 引入的loading图标
  27. background: 'rgba(0, 0, 0, 0.7)', // 背景颜色
  28. // target: '.main', // 需要遮罩的区域
  29. body: true,
  30. // customClass: 'mask' // 遮罩层新增类名
  31. })
  32. setTimeout(function () { // 设定定时器,超时5S后自动关闭遮罩层,避免请求失败时,遮罩层一直存在的问题
  33. loading.close(); // 关闭遮罩层
  34. },500)
  35. return loading;
  36. }
  37. /* eslint-disable no-new */
  38. new Vue({
  39. el: '#app',
  40. router,
  41. store, //使用store vuex状态管理
  42. components: { App },
  43. template: '<App/>',
  44. })