icons.vue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. <template>
  2. <view>
  3. <view class="uni-header">
  4. <view class="uni-group">
  5. <view class="uni-title">{{$t('demo.icons.title')}}(uni-icons)</view>
  6. <view class="uni-sub-title">{{$t('demo.icons.describle')}}</view>
  7. </view>
  8. </view>
  9. <view class="uni-container">
  10. <view class="icons">
  11. <view v-for="(icon,index) in icons" :key="index" class="icon-item pointer">
  12. <view @click="setClipboardData('tag',icon)" :class="'uni-icons-'+icon"></view>
  13. <text @click="setClipboardData('class',icon)" class="icon-text">uni-icons-{{icon}}</text>
  14. </view>
  15. </view>
  16. </view>
  17. <!-- #ifndef H5 -->
  18. <fix-window v-if="fixWindow" />
  19. <!-- #endif -->
  20. </view>
  21. </template>
  22. <script>
  23. import icons from './uni-icons.js'
  24. export default {
  25. data() {
  26. return {
  27. icons
  28. }
  29. },
  30. props:{
  31. tag: {
  32. type: Boolean,
  33. default: true
  34. },
  35. fixWindow: {
  36. type: Boolean,
  37. default: true
  38. }
  39. },
  40. methods: {
  41. setClipboardData(type, icon) {
  42. let data = 'uni-icons-' + icon
  43. if (this.tag && type === 'tag') {
  44. data = '<view class="' + data + '"></view>'
  45. }
  46. uni.setClipboardData({
  47. data,
  48. success(res) {
  49. uni.showToast({
  50. icon: 'none',
  51. title: '复制 ' + data + ' 成功!'
  52. })
  53. },
  54. fail(res) {
  55. uni.showModal({
  56. content: '复制 ' + data + ' 失败!',
  57. showCancel: false
  58. })
  59. }
  60. })
  61. }
  62. }
  63. }
  64. </script>
  65. <style lang="scss">
  66. /* #ifndef H5 */
  67. page {
  68. padding-top: 85px;
  69. }
  70. /* #endif */
  71. .icons {
  72. display: flex;
  73. flex-direction: row;
  74. flex-wrap: wrap;
  75. }
  76. .icon-item {
  77. display: flex;
  78. width: 16.6%;
  79. height: 120px;
  80. font-size: 30px;
  81. text-align: center;
  82. justify-content: center;
  83. align-items: center;
  84. flex-direction: column;
  85. }
  86. .icon-item:hover,
  87. .icon-item:hover .icon-text {
  88. color: $uni-color-primary;
  89. }
  90. .icon-text {
  91. color: #99a9bf;
  92. font-size: 12px;
  93. text-align: center;
  94. height: 1em;
  95. line-height: 1em;
  96. margin-top: 15px;
  97. }
  98. /* #ifdef H5 */
  99. @media only screen and (max-width: 500px) {
  100. .icon-item {
  101. width: 33.3%;
  102. }
  103. }
  104. /* #endif */
  105. </style>