You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import 'babel-polyfill';
  2. //#pragma warning(disable:18)
  3. import { createApp, createVNode } from 'vue'
  4. import App from './App.vue'
  5. import router from './router/index' //路由
  6. //element-plus 组件相关
  7. import ElementPlus from 'element-plus'
  8. import 'element-plus/dist/index.css'
  9. import zhCn from 'element-plus/es/locale/lang/zh-cn'
  10. import * as EleIcons from '@element-plus/icons-vue'
  11. //fragment
  12. import Fragment from 'vue-fragment'
  13. //全局样式
  14. import './style/main.css'
  15. import { isValidKey } from '@/utils/utils'
  16. //请求
  17. import * as request from '@/api/index'
  18. const app = createApp(App)
  19. //全局注册请求
  20. app.config.globalProperties.$request = request;
  21. app.use(router)
  22. .use(Fragment.Plugin)
  23. .use(ElementPlus, { // 使用element-plus
  24. locale: zhCn,
  25. }).mount('#app')
  26. //全局图标组件
  27. for (const name in EleIcons) {
  28. if (isValidKey(name, EleIcons)) {
  29. app.component(name, EleIcons[name]) //添加图标组件
  30. }
  31. }
  32. // 下面为全局注册图标组件
  33. // 创建Icon组件
  34. const Icon = (props: { icon: string }) => {
  35. const { icon } = props
  36. return createVNode(EleIcons[icon as keyof typeof EleIcons])
  37. }
  38. // 注册Icon组件
  39. app.component('Icon', Icon)