main.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. import {createSSRApp} from 'vue'
  2. import store from './store'
  3. import App from './App'
  4. /**
  5. * 所有测试用数据均存放于根目录json.js
  6. *
  7. * css部分使用了App.vue下的全局样式和iconfont图标,有需要图标库的可以留言。
  8. * 示例使用了uni.scss下的变量, 除变量外已尽量移除特有语法,可直接替换为其他预处理器使用
  9. */
  10. const msg = (title, duration=1500, mask=false, icon='none')=>{
  11. if(Boolean(title) === false){
  12. return;
  13. }
  14. return uni.showToast({
  15. title,
  16. duration,
  17. mask,
  18. icon
  19. });
  20. }
  21. const prePage = ()=>{
  22. let pages = getCurrentPages();
  23. let prePage = pages[pages.length - 2];
  24. // #ifdef H5
  25. return prePage;
  26. // #endif
  27. return prePage.$vm;
  28. }
  29. // Vue.config.productionTip = false
  30. // Vue.prototype.$fire = new Vue();
  31. // Vue.prototype.$store = store;
  32. // Vue.prototype.$api = {msg, prePage};
  33. // App.mpType = 'app'
  34. // const app = new Vue({
  35. // ...App
  36. // })
  37. // app.$mount()
  38. export function createApp() {
  39. const app = createSSRApp(App)
  40. app.use(store)
  41. console.log(msg,'msg')
  42. app.config.globalProperties.$api = {msg,prePage};
  43. app.config.globalProperties.$prePage =prePage;
  44. app.config.globalProperties.$msg = msg;
  45. return {
  46. app
  47. }
  48. }
  49. // app.