index.vue 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <template>
  2. <div class="element-container">
  3. <el-card shadow="hover" :header="`element plus 字体图标(自动载入,增加了 ele- 前缀,使用时:ele-Aim):${sheetsIconList.length}个`">
  4. <el-row class="iconfont-row">
  5. <el-col :xs="12" :sm="8" :md="6" :lg="4" :xl="2" v-for="(v, k) in sheetsIconList" :key="k">
  6. <div class="iconfont-warp">
  7. <div class="flex-margin">
  8. <div class="iconfont-warp-value">
  9. <SvgIcon :name="v" :size="30" />
  10. </div>
  11. <div class="iconfont-warp-label mt10">{{ v }}</div>
  12. </div>
  13. </div>
  14. </el-col>
  15. </el-row>
  16. </el-card>
  17. </div>
  18. </template>
  19. <script lang="ts">
  20. import { toRefs, reactive, onMounted, defineComponent } from 'vue';
  21. import initIconfont from '/@/utils/getStyleSheets';
  22. export default defineComponent({
  23. name: 'pagesElement',
  24. setup() {
  25. const state = reactive({
  26. sheetsIconList: [],
  27. });
  28. // 初始化获取 css 样式,获取 element plus 自带 svg 图标,增加了 ele- 前缀,使用时:ele-Aim
  29. const initGetStyleSheets = () => {
  30. initIconfont.ele().then((res: any) => {
  31. state.sheetsIconList = res;
  32. });
  33. };
  34. // 页面加载时
  35. onMounted(() => {
  36. initGetStyleSheets();
  37. });
  38. return {
  39. ...toRefs(state),
  40. };
  41. },
  42. });
  43. </script>
  44. <style scoped lang="scss">
  45. .element-container {
  46. .iconfont-row {
  47. border-top: 1px solid var(--next-border-color-light);
  48. border-left: 1px solid var(--next-border-color-light);
  49. .iconfont-warp {
  50. text-align: center;
  51. border-right: 1px solid var(--next-border-color-light);
  52. border-bottom: 1px solid var(--next-border-color-light);
  53. height: 120px;
  54. overflow: hidden;
  55. display: flex;
  56. transition: all 0.3s ease;
  57. &:hover {
  58. box-shadow: 0 2px 12px var(--next-color-dark-hover);
  59. cursor: pointer;
  60. transition: all 0.3s ease;
  61. .iconfont-warp-value {
  62. i {
  63. color: var(--el-color-primary);
  64. transition: all 0.3s ease;
  65. }
  66. }
  67. .iconfont-warp-label {
  68. color: var(--el-color-primary);
  69. transition: all 0.3s ease;
  70. }
  71. }
  72. .iconfont-warp-value {
  73. i {
  74. color: #606266;
  75. font-size: 32px;
  76. transition: all 0.3s ease;
  77. }
  78. }
  79. .iconfont-warp-label {
  80. color: #99a9bf;
  81. transition: all 0.3s ease;
  82. }
  83. }
  84. }
  85. }
  86. </style>