main.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. import Vue from 'vue'
  2. import App from './App'
  3. import store from '@/store';
  4. import Loading from '@/components/window-loading/index.vue'
  5. Vue.config.productionTip = false;
  6. App.mpType = 'app';
  7. // 引入全局uView
  8. import uView from 'uview-ui'
  9. Vue.use(uView);
  10. // 引入vuex
  11. const vuexStore = require("@/store/$u.mixin.js");
  12. Vue.mixin(vuexStore);
  13. // 创建对象
  14. const app = new Vue({
  15. store,
  16. ...App
  17. });
  18. // 接口集中管理
  19. import httpInstall from '@/http/install.js'
  20. Vue.use(httpInstall, app)
  21. import http from '@/http/api.js'
  22. Vue.prototype.$http = http
  23. // 公共函数
  24. import globalFunc from '@/utils/func.js'
  25. Vue.use(globalFunc, app);
  26. // #ifdef H5
  27. Vue.directive('loading', {
  28. bind(el, binding) {
  29. const loading = new Vue({
  30. data: {
  31. isLoading: binding.value
  32. },
  33. render(h) {
  34. return h(Loading, {
  35. props: {
  36. isLoading: this.isLoading
  37. }
  38. })
  39. }
  40. }).$mount()
  41. el.appendChild(loading.$el)
  42. },
  43. update(el, binding) {
  44. if (binding.value !== binding.oldValue) {
  45. el.querySelector('.loading-mask').style.display = binding.value ? 'block' : 'none'
  46. }
  47. }
  48. })
  49. // #endif
  50. app.$mount()