main.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. // i18n部分的配置
  19. // 引入语言包,注意路径
  20. import Chinese from '@/common/locales/zh.js';
  21. import English from '@/common/locales/en.js';
  22. // VueI18n
  23. import VueI18n from '@/common/vue-i18n.min.js'
  24. // VueI18n
  25. Vue.use(VueI18n)
  26. const i18n = new VueI18n({
  27. // 默认语言
  28. locale: 'zh',
  29. // 引入语言文件
  30. messages: {
  31. 'zh': Chinese,
  32. 'en': English,
  33. }
  34. })
  35. // 由于微信小程序的运行机制问题,需声明如下一行,H5和APP非必填
  36. Vue.prototype._i18n = i18n
  37. const app = new Vue({
  38. i18n,
  39. store,
  40. ...App
  41. })
  42. // http拦截器,将此部分放在new Vue()和app.$mount()之间,才能App.vue中正常使用
  43. import httpInterceptor from '@/common/http.interceptor.js'
  44. Vue.use(httpInterceptor, app)
  45. // http接口API抽离,免于写url或者一些固定的参数
  46. import httpApi from '@/common/http.api.js'
  47. Vue.use(httpApi, app)
  48. app.$mount()
  49. //扫码组件
  50. import scan from '@/common/p-scan/scan.vue'
  51. Vue.component('scan', scan)