main.js 1.2 KB

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