main.js 1003 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import App from './App'
  2. import {
  3. _router,
  4. parseRoute
  5. } from '@/utils'
  6. // #ifndef VUE3
  7. import Vue from 'vue'
  8. import __config from 'config/index';
  9. Vue.config.productionTip = false
  10. Vue.prototype.$onLaunched = new Promise(resolve => {
  11. Vue.prototype.$isResolve = resolve
  12. })
  13. Vue.prototype.baseImagePath = __config.baseImagePath;
  14. App.mpType = 'app'
  15. const app = new Vue({
  16. ...App
  17. })
  18. Object.defineProperty(Vue.prototype, '$yrouter', {
  19. get() {
  20. return _router
  21. },
  22. })
  23. Object.defineProperty(Vue.prototype, '$yroute', {
  24. get() {
  25. return this._route
  26. },
  27. })
  28. Vue.mixin({
  29. onLoad() {
  30. const {
  31. $mp
  32. } = this.$root
  33. this._route = parseRoute($mp)
  34. },
  35. onShow() {
  36. _router.app = this
  37. _router.currentRoute = this._route
  38. },
  39. // 这里为了解决 .vue文件中 template 无法获取 VUE.prototype 绑定的变量
  40. computed: {
  41. },
  42. })
  43. app.$mount()
  44. // #endif
  45. // #ifdef VUE3
  46. import { createSSRApp } from 'vue'
  47. export function createApp() {
  48. const app = createSSRApp(App)
  49. return {
  50. app
  51. }
  52. }
  53. // #endif