main.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import Vue from "vue";
  2. import App from "./App.vue";
  3. import store from "./store/index";
  4. // 路由
  5. import router from "./router";
  6. import axios from "@/utils/axios";
  7. import API from "@/api";
  8. // 共通filters
  9. import * as filters from "./filters";
  10. // 设置字体大小
  11. import "@/utils/rem";
  12. import "@/common/permission";
  13. import { Button, Image, Dialog, NavBar, Tabbar, TabbarItem, Tabs, Tab } from "vant";
  14. window.$_http = axios;
  15. // event Bus 用于无关系组件间的通信。
  16. Vue.prototype.$bus = new Vue();
  17. Vue.prototype.$_http = axios;
  18. Vue.prototype.$_API = API;
  19. Vue.component("VanButton", Button);
  20. Vue.component("VanImage", Image);
  21. Vue.component("VanDialog", Dialog);
  22. Vue.component("VanNavBar", NavBar);
  23. Vue.component("VanTabbar", Tabbar);
  24. Vue.component("VanTabbarItem", TabbarItem);
  25. Vue.component("VanTabs", Tabs);
  26. Vue.component("VanTab", Tab);
  27. Object.entries(filters).forEach(([key, value]) => {
  28. Vue.filter(key, value);
  29. });
  30. router.beforeEach(async (to, from, next) => {
  31. console.warn(to.name, to);
  32. try {
  33. } catch (error) {
  34. console.error(error);
  35. }
  36. next();
  37. });
  38. new Vue({
  39. router,
  40. store,
  41. render: h => h(App)
  42. }).$mount("#app");