main.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. Vue.use(ElementUI,{locale})
  14. Vue.prototype.$webSocket = webSocketService;
  15. Vue.config.productionTip = false
  16. Vue.prototype.$axios = axios
  17. Vue.directive('clickoutside', {
  18. bind (el, binding, vnode) {
  19. function documentHandler (e) {
  20. if (el.contains(e.target)) {
  21. return false
  22. }
  23. if (binding.expression) {
  24. binding.value(e)
  25. }
  26. }
  27. el.__vueClickOutside__ = documentHandler
  28. document.addEventListener('click', documentHandler)
  29. },
  30. unbind (el, binding) {
  31. document.removeEventListener('click', el.__vueClickOutside__)
  32. delete el.__vueClickOutside__
  33. }
  34. })
  35. /* eslint-disable no-new */
  36. const appVue = new Vue({
  37. el: '#app',
  38. render: h => h(App),
  39. router,
  40. components: {App},
  41. template: '<App/>'
  42. })