main.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. import Vue from 'vue';
  2. import App from './App';
  3. Vue.config.productionTip = false;
  4. App.mpType = 'app';
  5. // 引入全局uView
  6. import uView from 'uview-ui';
  7. Vue.use(uView);
  8. // 此处为演示vuex使用,非uView的功能部分
  9. import store from '@/store';
  10. // 引入uView提供的对vuex的简写法文件
  11. let vuexStore = require('@/store/$u.mixin.js');
  12. Vue.mixin(vuexStore);
  13. // 引入uView对小程序分享的mixin封装
  14. let mpShare = require('uview-ui/libs/mixin/mpShare.js');
  15. Vue.mixin(mpShare);
  16. import * as util from './core/util.js';
  17. import moment from './core/unpkg/moment.js';
  18. import site from './core/site.js';
  19. import $const from './core/constant.js';
  20. import jump from './core/jump.js';
  21. Vue.use({
  22. install(Vue, options) {
  23. // 配置
  24. Vue.prototype.$site = site;
  25. Vue.prototype.$moment = moment;
  26. //
  27. Vue.prototype.$util = util;
  28. // 常量
  29. Vue.prototype.$const = $const;
  30. // 路由
  31. Vue.prototype.$jump = jump;
  32. // 平台
  33. Vue.prototype.$platform = uni.getSystemInfoSync().platform
  34. }
  35. });
  36. const app = new Vue({
  37. store,
  38. ...App
  39. });
  40. // http拦截器,将此部分放在new Vue()和app.$mount()之间,才能App.vue中正常使用
  41. import httpInterceptor from '@/core/http.interceptor.js';
  42. Vue.use(httpInterceptor, app);
  43. // http接口API抽离,免于写url或者一些固定的参数
  44. import httpApi from '@/core/http.api.js';
  45. Vue.use(httpApi, app);
  46. app.$mount();