elementPlus.ts 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. // 按需引入element-plus(该方法稳定且明确。当然也支持:https://element-plus.org/zh-CN/guide/quickstart.html#%E6%8C%89%E9%9C%80%E5%AF%BC%E5%85%A5)
  2. import type { App, Component } from "vue";
  3. import {
  4. /**
  5. * 为了方便演示平台将 element-plus 导出的所有组件引入,实际使用中如果你没用到哪个组件,将其注释掉就行
  6. * 导出来源:https://github.com/element-plus/element-plus/blob/dev/packages/element-plus/component.ts#L111-L211
  7. * */
  8. ElAffix,
  9. ElAlert,
  10. ElAutocomplete,
  11. ElAutoResizer,
  12. ElAvatar,
  13. ElAnchor,
  14. ElAnchorLink,
  15. ElBacktop,
  16. ElBadge,
  17. ElBreadcrumb,
  18. ElBreadcrumbItem,
  19. ElButton,
  20. ElButtonGroup,
  21. ElCalendar,
  22. ElCard,
  23. ElCarousel,
  24. ElCarouselItem,
  25. ElCascader,
  26. ElCascaderPanel,
  27. ElCheckTag,
  28. ElCheckbox,
  29. ElCheckboxButton,
  30. ElCheckboxGroup,
  31. ElCol,
  32. ElCollapse,
  33. ElCollapseItem,
  34. ElCollapseTransition,
  35. ElColorPicker,
  36. ElConfigProvider,
  37. ElContainer,
  38. ElAside,
  39. ElFooter,
  40. ElHeader,
  41. ElMain,
  42. ElDatePicker,
  43. ElDescriptions,
  44. ElDescriptionsItem,
  45. ElDialog,
  46. ElDivider,
  47. ElDrawer,
  48. ElDropdown,
  49. ElDropdownItem,
  50. ElDropdownMenu,
  51. ElEmpty,
  52. ElForm,
  53. ElFormItem,
  54. ElIcon,
  55. ElImage,
  56. ElImageViewer,
  57. ElInput,
  58. ElInputNumber,
  59. ElLink,
  60. ElMenu,
  61. ElMenuItem,
  62. ElMenuItemGroup,
  63. ElSubMenu,
  64. ElPageHeader,
  65. ElPagination,
  66. ElPopconfirm,
  67. ElPopover,
  68. ElPopper,
  69. ElProgress,
  70. ElRadio,
  71. ElRadioButton,
  72. ElRadioGroup,
  73. ElRate,
  74. ElResult,
  75. ElRow,
  76. ElScrollbar,
  77. ElSelect,
  78. ElOption,
  79. ElOptionGroup,
  80. ElSelectV2,
  81. ElSkeleton,
  82. ElSkeletonItem,
  83. ElSlider,
  84. ElSpace,
  85. ElStatistic,
  86. ElCountdown,
  87. ElSteps,
  88. ElStep,
  89. ElSwitch,
  90. ElTable,
  91. ElTableColumn,
  92. ElTableV2,
  93. ElTabs,
  94. ElTabPane,
  95. ElTag,
  96. ElText,
  97. ElTimePicker,
  98. ElTimeSelect,
  99. ElTimeline,
  100. ElTimelineItem,
  101. ElTooltip,
  102. ElTransfer,
  103. ElTree,
  104. ElTreeSelect,
  105. ElTreeV2,
  106. ElUpload,
  107. ElWatermark,
  108. ElTour,
  109. ElTourStep,
  110. /**
  111. * 为了方便演示平台将 element-plus 导出的所有插件引入,实际使用中如果你没用到哪个插件,将其注释掉就行
  112. * 导出来源:https://github.com/element-plus/element-plus/blob/dev/packages/element-plus/plugin.ts#L11-L16
  113. * */
  114. ElLoading, // v-loading 指令
  115. ElInfiniteScroll, // v-infinite-scroll 指令
  116. ElPopoverDirective, // v-popover 指令
  117. ElMessage, // $message 全局属性对象globalProperties
  118. ElMessageBox, // $msgbox、$alert、$confirm、$prompt 全局属性对象globalProperties
  119. ElNotification // $notify 全局属性对象globalProperties
  120. } from "element-plus";
  121. const components = [
  122. ElAffix,
  123. ElAlert,
  124. ElAutocomplete,
  125. ElAutoResizer,
  126. ElAvatar,
  127. ElAnchor,
  128. ElAnchorLink,
  129. ElBacktop,
  130. ElBadge,
  131. ElBreadcrumb,
  132. ElBreadcrumbItem,
  133. ElButton,
  134. ElButtonGroup,
  135. ElCalendar,
  136. ElCard,
  137. ElCarousel,
  138. ElCarouselItem,
  139. ElCascader,
  140. ElCascaderPanel,
  141. ElCheckTag,
  142. ElCheckbox,
  143. ElCheckboxButton,
  144. ElCheckboxGroup,
  145. ElCol,
  146. ElCollapse,
  147. ElCollapseItem,
  148. ElCollapseTransition,
  149. ElColorPicker,
  150. ElConfigProvider,
  151. ElContainer,
  152. ElAside,
  153. ElFooter,
  154. ElHeader,
  155. ElMain,
  156. ElDatePicker,
  157. ElDescriptions,
  158. ElDescriptionsItem,
  159. ElDialog,
  160. ElDivider,
  161. ElDrawer,
  162. ElDropdown,
  163. ElDropdownItem,
  164. ElDropdownMenu,
  165. ElEmpty,
  166. ElForm,
  167. ElFormItem,
  168. ElIcon,
  169. ElImage,
  170. ElImageViewer,
  171. ElInput,
  172. ElInputNumber,
  173. ElLink,
  174. ElMenu,
  175. ElMenuItem,
  176. ElMenuItemGroup,
  177. ElSubMenu,
  178. ElPageHeader,
  179. ElPagination,
  180. ElPopconfirm,
  181. ElPopover,
  182. ElPopper,
  183. ElProgress,
  184. ElRadio,
  185. ElRadioButton,
  186. ElRadioGroup,
  187. ElRate,
  188. ElResult,
  189. ElRow,
  190. ElScrollbar,
  191. ElSelect,
  192. ElOption,
  193. ElOptionGroup,
  194. ElSelectV2,
  195. ElSkeleton,
  196. ElSkeletonItem,
  197. ElSlider,
  198. ElSpace,
  199. ElStatistic,
  200. ElCountdown,
  201. ElSteps,
  202. ElStep,
  203. ElSwitch,
  204. ElTable,
  205. ElTableColumn,
  206. ElTableV2,
  207. ElTabs,
  208. ElTabPane,
  209. ElTag,
  210. ElText,
  211. ElTimePicker,
  212. ElTimeSelect,
  213. ElTimeline,
  214. ElTimelineItem,
  215. ElTooltip,
  216. ElTransfer,
  217. ElTree,
  218. ElTreeSelect,
  219. ElTreeV2,
  220. ElUpload,
  221. ElWatermark,
  222. ElTour,
  223. ElTourStep
  224. ];
  225. const plugins = [
  226. ElLoading,
  227. ElInfiniteScroll,
  228. ElPopoverDirective,
  229. ElMessage,
  230. ElMessageBox,
  231. ElNotification
  232. ];
  233. /** 按需引入`element-plus` */
  234. export function useElementPlus(app: App) {
  235. // 全局注册组件
  236. components.forEach((component: Component) => {
  237. app.component(component.name, component);
  238. });
  239. // 全局注册插件
  240. plugins.forEach(plugin => {
  241. app.use(plugin);
  242. });
  243. }