main.js 1.1 KB

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