main.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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 vant, { Toast } from 'vant'
  10. import 'vant/lib/index.css';
  11. // Date 扩展插件
  12. import 'datejs'
  13. import './assets/css/base.scss';
  14. import './assets/css/ui.scss';
  15. // 自定义指令
  16. import '@/directive/blMobile'
  17. Vue.mixin({
  18. data() {
  19. let route = this.$route || {}
  20. return {
  21. vueRouteName: route.name
  22. }
  23. },
  24. watch: {
  25. $route(to, from) {
  26. if (to.name === this.vueRouteName) {
  27. this.vueWatchRoute && this.vueWatchRoute(to, from)
  28. }
  29. }
  30. },
  31. created () {
  32. if ('TITLE' in this) {
  33. this.$store.commit('SET_HEADER_TITLE', this.TITLE)
  34. }
  35. }
  36. })
  37. Vue.use(vant);
  38. Vue.use(http);
  39. Vue.use(blRule);
  40. Vue.config.productionTip = false
  41. // Toast 多个Toast
  42. Toast.allowMultiple()
  43. // 将所有 Toast 的展示时长设置为 2000 毫秒
  44. Toast.setDefaultOptions({ duration: 3000 });
  45. Toast.setDefaultOptions('loading', { forbidClick: true });
  46. /* eslint-disable no-new */
  47. new Vue({
  48. el: '#app',
  49. router,
  50. store,
  51. components: { App },
  52. template: '<App/>'
  53. })