main.js 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. import Vue from 'vue';
  2. import App from './App';
  3. Vue.config.productionTip = false;
  4. App.mpType = 'app';
  5. // 此处为演示Vue.prototype使用,非uView的功能部分
  6. Vue.prototype.vuePrototype = '枣红';
  7. // 引入全局uView
  8. import uView from 'uview-ui';
  9. Vue.use(uView);
  10. // 此处为演示vuex使用,非uView的功能部分
  11. import store from '@/store';
  12. // 引入uView提供的对vuex的简写法文件
  13. let vuexStore = require('@/store/$u.mixin.js');
  14. Vue.mixin(vuexStore);
  15. // 引入uView对小程序分享的mixin封装
  16. let mpShare = require('uview-ui/libs/mixin/mpShare.js');
  17. Vue.mixin(mpShare);
  18. // main.js
  19. import tabBar from 'components/tabbar.vue'
  20. Vue.component('tab-bar', tabBar) //挂载
  21. import HeaderNav from 'components/HeaderNav.vue'
  22. Vue.component('header-nav', HeaderNav)
  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. // import axios from 'axios'
  32. // Vue.prototype.$axios = axios;
  33. const i18n = new VueI18n({
  34. // 默认语言
  35. locale: 'zh',
  36. // 引入语言文件
  37. messages: {
  38. 'zh': Chinese,
  39. 'en': English,
  40. }
  41. });
  42. // 由于微信小程序的运行机制问题,需声明如下一行,H5和APP非必填
  43. Vue.prototype._i18n = i18n;
  44. const app = new Vue({
  45. i18n,
  46. store,
  47. ...App
  48. });
  49. // http拦截器,将此部分放在new Vue()和app.$mount()之间,才能App.vue中正常使用
  50. import httpInterceptor from '@/common/http.interceptor.js';
  51. Vue.use(httpInterceptor, app);
  52. // http接口API抽离,免于写url或者一些固定的参数
  53. import httpApi from '@/common/http.api.js';
  54. Vue.use(httpApi, app);
  55. //全局方法判断权限
  56. import $p from './common/public.js'
  57. Vue.prototype.$transformAuth = $p.transformAuth
  58. //转换日期
  59. Vue.prototype.$transformWeek = $p.transformWeek
  60. app.$mount();