main.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import Vue from 'vue'
  2. import App from '@/App'
  3. import { router, RouterMount } from '@/router/index.js'
  4. import LoadingPlugin from '@/plugins/loading.js'
  5. import '@/utils/filter.js'
  6. import uView from 'uview-ui'
  7. // 此处为演示vuex使用,非uView的功能部分
  8. import store from '@/store'
  9. import { pcLogin } from './api/user'
  10. // 引入uView对小程序分享的mixin封装
  11. const mpShare = require('uview-ui/libs/mixin/mpShare.js')
  12. // 引入uView提供的对vuex的简写法文件
  13. import vuexStore from '@/store/$u.mixin.js'
  14. import { sleep } from './utils/utils'
  15. Vue.mixin(vuexStore)
  16. Vue.mixin(mpShare)
  17. Vue.use(router)
  18. Vue.use(uView)
  19. Vue.use(LoadingPlugin)
  20. Vue.config.productionTip = false
  21. // 小程序页面组件和这个 App.vue 组件的写法和引入方式是一致的,为了区分两者,需要设置mpType值
  22. App.mpType = 'app'
  23. pcLogin().then((res) => {
  24. uni.setStorageSync('user', res)
  25. })
  26. const app = new Vue({
  27. store,
  28. ...App
  29. })
  30. //v1.3.5起 H5端 你应该去除原有的app.$mount();使用路由自带的渲染方式
  31. // #ifdef H5
  32. RouterMount(app, router, '#app')
  33. // #endif
  34. // #ifndef H5
  35. app.$mount() //为了兼容小程序及app端必须这样写才有效果
  36. // #endif
  37. export default app