main.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. import Vue from 'vue';
  2. import App from './App';
  3. import http from './plugins/http';
  4. import Vuex from 'vuex';
  5. Vue.config.productionTip = false;
  6. App.mpType = 'app';
  7. // 此处为演示Vue.prototype使用,非uView的功能部分
  8. Vue.prototype.vuePrototype = '枣红';
  9. Vue.use(http);
  10. Vue.use(Vuex);
  11. Vue.prototype.$colors = {
  12. prim: '#214BBE'
  13. };
  14. // 引入全局uView
  15. import uView from 'uview-ui';
  16. Vue.use(uView);
  17. // 此处为演示vuex使用,非uView的功能部分
  18. const store = require('./store').default;
  19. Vue.prototype.$store = store;
  20. // 引入uView对小程序分享的mixin封装
  21. let mpShare = require('uview-ui/libs/mixin/mpShare.js');
  22. Vue.mixin(mpShare);
  23. // i18n部分的配置
  24. // 引入语言包,注意路径
  25. import Chinese from '@/common/locales/zh.js';
  26. import English from '@/common/locales/en.js';
  27. // VueI18n
  28. import VueI18n from '@/common/vue-i18n.min.js';
  29. // VueI18n
  30. Vue.use(VueI18n);
  31. const i18n = new VueI18n({
  32. // 默认语言
  33. locale: 'zh',
  34. // 引入语言文件
  35. messages: {
  36. 'zh': Chinese,
  37. 'en': English,
  38. }
  39. });
  40. // 由于微信小程序的运行机制问题,需声明如下一行,H5和APP非必填
  41. Vue.prototype._i18n = i18n;
  42. const app = new Vue({
  43. i18n,
  44. store,
  45. ...App
  46. });
  47. // http拦截器,将此部分放在new Vue()和app.$mount()之间,才能App.vue中正常使用
  48. import httpInterceptor from '@/common/http.interceptor.js';
  49. Vue.use(httpInterceptor, app);
  50. // http接口API抽离,免于写url或者一些固定的参数
  51. import httpApi from '@/common/http.api.js';
  52. Vue.use(httpApi, app);
  53. app.$mount();