main.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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 ElementUI from 'element-ui'
  5. import locale from 'element-ui/lib/locale/lang/en'
  6. import 'element-ui/lib/theme-chalk/index.css'
  7. import App from './App'
  8. import router from './router'
  9. // import axios from 'axios'
  10. import axios from './utils/axiosPlugin'
  11. import errorInfo from './utils/errorCode'
  12. import webSocketService from './utils/websocket';
  13. import moment from 'moment'
  14. Vue.prototype.$moment = moment
  15. Vue.use(ElementUI,{locale})
  16. Vue.prototype.$webSocket = webSocketService;
  17. Vue.config.productionTip = false
  18. Vue.prototype.$axios = axios
  19. Vue.directive('clickoutside', {
  20. bind (el, binding, vnode) {
  21. function documentHandler (e) {
  22. if (el.contains(e.target)) {
  23. return false
  24. }
  25. if (binding.expression) {
  26. binding.value(e)
  27. }
  28. }
  29. el.__vueClickOutside__ = documentHandler
  30. document.addEventListener('click', documentHandler)
  31. },
  32. unbind (el, binding) {
  33. document.removeEventListener('click', el.__vueClickOutside__)
  34. delete el.__vueClickOutside__
  35. }
  36. })
  37. /* eslint-disable no-new */
  38. const appVue = new Vue({
  39. el: '#app',
  40. render: h => h(App),
  41. router,
  42. components: {App},
  43. template: '<App/>'
  44. })