main.js 1013 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import Vue from 'vue';
  2. import App from './App';
  3. import uView from 'uview-ui';
  4. import { router, RouterMount } from '@/router'; //路径换成自己的
  5. import store from '@/store';
  6. import cache from '@/mixin/cache';
  7. import empty from '@/components/empty';
  8. App.mpType = 'app';
  9. import '@/static/iconfont.css' // iconfont的引入
  10. Vue.use(router);
  11. Vue.use(uView);
  12. Vue.mixin(cache);
  13. Vue.component('empty', empty);
  14. Vue.config.productionTip = false;
  15. App.mpType = 'app';
  16. function isPromise(obj) {
  17. return !!obj && (typeof obj === 'object' || typeof obj === 'function') && typeof obj.then === 'function';
  18. }
  19. uni.addInterceptor({
  20. returnValue(res) {
  21. if (!isPromise(res)) {
  22. return res;
  23. }
  24. return new Promise((resolve, reject) => {
  25. res.then(res => {
  26. if (res[0]) {
  27. reject(res[0]);
  28. } else {
  29. resolve(res[1]);
  30. }
  31. });
  32. });
  33. },
  34. });
  35. const app = new Vue({
  36. store,
  37. ...App,
  38. });
  39. // #ifdef H5
  40. RouterMount(app, router, '#app');
  41. // #endif
  42. app.$mount();