main.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. // The Vue build version to load with the `import` command
  2. // (runtime-only or standalone) has been set in webpack.base.conf with an alias.
  3. import Vue from 'vue'
  4. import App from './App'
  5. import router from './router'
  6. import store from './store'
  7. import http from '@/utils/http/init';
  8. import blRule from '@/utils/blRule';
  9. import ViewScroll from '@/components/ViewScroll'
  10. import vant, { Toast } from 'vant'
  11. import 'vant/lib/index.css';
  12. // Date 扩展插件
  13. import 'datejs'
  14. import './assets/css/base.scss';
  15. import './assets/css/ui.scss';
  16. // 自定义指令
  17. import '@/directive/blMobile'
  18. import '@/directive/blBr'
  19. Vue.mixin({
  20. data() {
  21. let route = this.$route || {}
  22. return {
  23. vueRouteName: route.name
  24. }
  25. },
  26. watch: {
  27. $route(to, from) {
  28. if (to.name === this.vueRouteName) {
  29. this.vueWatchRoute && this.vueWatchRoute(to, from)
  30. }
  31. }
  32. },
  33. created () {
  34. if ('TITLE' in this) {
  35. this.$store.commit('SET_HEADER_TITLE', this.TITLE)
  36. }
  37. }
  38. })
  39. Vue.component('view-scroll', ViewScroll)
  40. Vue.use(vant);
  41. Vue.use(http);
  42. Vue.use(blRule);
  43. Vue.config.productionTip = false
  44. // Toast 多个Toast
  45. Toast.allowMultiple()
  46. // 将所有 Toast 的展示时长设置为 2000 毫秒
  47. Toast.setDefaultOptions({ duration: 3000 });
  48. Toast.setDefaultOptions('loading', { forbidClick: true });
  49. /* eslint-disable no-new */
  50. new Vue({
  51. el: '#app',
  52. router,
  53. store,
  54. components: { App },
  55. template: '<App/>'
  56. })