main.js 986 B

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