font-family-icon.uvue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. <template>
  2. <!-- #ifdef APP -->
  3. <scroll-view style="flex: 1;">
  4. <!-- #endif -->
  5. <view style="align-items: center;align-self: center;">
  6. <view class="iconContainer">
  7. <view class="iconItem" v-for="item in uniIcons">
  8. <text class="icon" :style="{'font-weight': fontWeight, 'font-style': fontStyle}">{{String.fromCharCode(parseInt(item.code,16))}}</text>
  9. <text class="code">\u{{item.code}}</text>
  10. <text class="name">{{item.name}}</text>
  11. </view>
  12. </view>
  13. </view>
  14. <!-- #ifdef APP -->
  15. </scroll-view>
  16. <!-- #endif -->
  17. </template>
  18. <script lang="uts">
  19. type Icon = {
  20. name : string,
  21. code : string,
  22. }
  23. export default {
  24. data() {
  25. return {
  26. uniIcons: [ //图标数据
  27. {
  28. 'name':'back',
  29. 'code':'E601',
  30. },
  31. {
  32. 'name':'forward',
  33. 'code':'E600',
  34. },
  35. {
  36. 'name':'share',
  37. 'code':'E602',
  38. },
  39. {
  40. 'name':'favorites',
  41. 'code':'E604',
  42. },
  43. {
  44. 'name':'home',
  45. 'code':'E605',
  46. },
  47. {
  48. 'name':'more',
  49. 'code':'E606',
  50. },
  51. {
  52. 'name':'close',
  53. 'code':'E650',
  54. },
  55. {
  56. 'name':'down',
  57. 'code':'E661',
  58. },
  59. {
  60. 'name':'circle',
  61. 'code':'EA01',
  62. },
  63. {
  64. 'name':'warn',
  65. 'code':'EA0F',
  66. },
  67. {
  68. 'name':'info',
  69. 'code':'EA03',
  70. },
  71. {
  72. 'name':'info circle',
  73. 'code':'EA04',
  74. },
  75. {
  76. 'name':'success',
  77. 'code':'EA06',
  78. },
  79. {
  80. 'name':'success circle',
  81. 'code':'EA07',
  82. },
  83. {
  84. 'name':'success no circle',
  85. 'code':'EA08',
  86. },
  87. {
  88. 'name':'cancel circle',
  89. 'code':'EA0B',
  90. },
  91. {
  92. 'name':'clear',
  93. 'code':'EA14',
  94. },
  95. {
  96. 'name':'download',
  97. 'code':'EA19',
  98. },
  99. {
  100. 'name':'waitnig',
  101. 'code':'EA1E',
  102. },
  103. {
  104. 'name':'search',
  105. 'code':'EA23',
  106. }
  107. ] as Icon[],
  108. // 自动化测试
  109. fontWeight: 'normal',
  110. fontStyle: 'normal'
  111. }
  112. },
  113. methods: {
  114. // 自动化测试
  115. changeStyle() {
  116. this.fontWeight = 'bold';
  117. this.fontStyle = 'italic';
  118. }
  119. }
  120. }
  121. </script>
  122. <style>
  123. .iconContainer {
  124. flex-direction: row;
  125. flex-wrap: wrap;
  126. justify-content: center;
  127. }
  128. .iconItem {
  129. width: 100px;
  130. height: 150px;
  131. justify-content: center;
  132. align-items: center;
  133. }
  134. .icon {
  135. width: 48px;
  136. height: 48px;
  137. font-family: uni-icon;
  138. font-size: 42px;
  139. line-height: 48px;
  140. color: #333;
  141. margin-bottom: 8px;
  142. }
  143. .code {
  144. font-size: 14px;
  145. color: #f00;
  146. }
  147. .name {
  148. font-size: 12px;
  149. color: #000;
  150. }
  151. </style>