main.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. // #ifndef VUE3
  2. import Vue from 'vue'
  3. import App from './App'
  4. //导入网络请求包
  5. import {$http} from '@escook/request-miniprogram'
  6. //5.导入store的自定义模块
  7. import store from '@/information/store.js'
  8. //导入uView组件库
  9. import uView from '@/uni_modules/uview-ui'
  10. Vue.use(uView)
  11. //挂载到uni.$http上方便调用
  12. uni.$http = $http
  13. //请求根路径
  14. // $http.baseUrl = 'https://www.uinav.com'
  15. //挂载请求拦截器
  16. $http.beforeRequest = function(options) {
  17. uni.showLoading({
  18. title: '数据加载中...'
  19. })
  20. }
  21. //挂载响应拦截器
  22. $http.afterRequest = function() {
  23. uni.hideLoading()
  24. }
  25. //封装的展示消息提示方法
  26. uni.$showMsg = function(title = '请求失败', duration = 1500){
  27. uni.showToast({
  28. title,
  29. duration,
  30. icon: 'none'
  31. })
  32. }
  33. Vue.config.productionTip = false
  34. App.mpType = 'app'
  35. //app实例对象
  36. const app = new Vue({
  37. ...App,
  38. //6.挂载到app实例对象里
  39. store
  40. })
  41. app.$mount()
  42. // #endif
  43. // #ifdef VUE3
  44. import { createSSRApp } from 'vue'
  45. import App from './App.vue'
  46. export function createApp() {
  47. const app = createSSRApp(App)
  48. return {
  49. app
  50. }
  51. }
  52. // #endif