main.js 869 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. import App from './App'
  2. import store from './store'
  3. const msg = (title, duration = 1500, mask = false, icon = 'none') => {
  4. //统一提示方便全局修改
  5. if (Boolean(title) === false) {
  6. return;
  7. }
  8. uni.showToast({
  9. title,
  10. duration,
  11. mask,
  12. icon
  13. });
  14. }
  15. const prePage = () => {
  16. // 获取当前页面
  17. let pages = getCurrentPages();
  18. let prePage = pages[pages.length - 2];
  19. // #ifdef H5
  20. return prePage;
  21. // #endif
  22. return prePage.$vm;
  23. }
  24. // #ifndef VUE3
  25. Vue.config.productionTip = false
  26. Vue.prototype.$store = store;
  27. Vue.prototype.$api = {
  28. msg,
  29. prePage
  30. };
  31. App.mpType = 'app'
  32. const app = new Vue({
  33. store,
  34. ...App
  35. })
  36. app.$mount()
  37. // #endif
  38. // #ifdef VUE3
  39. import {
  40. createSSRApp
  41. } from 'vue'
  42. export function createApp() {
  43. const app = createSSRApp(App)
  44. app.use(store)
  45. app.config.globalProperties.$api = {
  46. msg,
  47. prePage
  48. }
  49. return {
  50. app
  51. }
  52. }
  53. // #endif