main.js 1.1 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 App from './App'
  5. import router from './router'
  6. import layout from './page/layout.vue'
  7. import iView from 'iview';
  8. import SMEditor from 'smeditor'
  9. import 'iview/dist/styles/iview.css';
  10. import Vuex from 'vuex'
  11. import axios from 'axios';
  12. import ElementUI from 'element-ui';
  13. import 'element-ui/lib/theme-chalk/index.css';
  14. axios.defaults.baseURL = 'http://localhost:8432/api';
  15. axios.defaults.headers.post['Content-Type'] = 'application/x-www-from-urlencoded';
  16. // 全局注册,之后可在其他组件中通过 this.$axios 发送数据
  17. Vue.prototype.$axios = axios;
  18. Vue.config.productionTip = false;
  19. Vue.use(Vuex);
  20. Vue.use(iView);
  21. Vue.use(SMEditor);
  22. Vue.use(ElementUI);
  23. const store = new Vuex.Store({
  24. state: {
  25. active: '',
  26. open: []
  27. },
  28. mutations: {
  29. updateActive(state,active){
  30. state.active = active;
  31. },
  32. updateOpen(state,open){
  33. state.open[0] = open;
  34. }
  35. }
  36. });
  37. /* eslint-disable no-new */
  38. new Vue({
  39. el: '#app',
  40. router,
  41. store,
  42. components: { layout },
  43. template: '<layout/>'
  44. })