demo.vue 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <template>
  2. <div>
  3. <p class="titlep">所有图标</p>
  4. <m-input v-model="keywords" placeholder="输入关键词进行搜索" @input="search"></m-input>
  5. <div class="iconListBox">
  6. <ul class="icon-list">
  7. <li v-for="(item,index) in iconData" :key="index">
  8. <i class="iconfont" :class=" 'icon-'+ item.name "></i>
  9. <span>{{item.name}}</span>
  10. </li>
  11. </ul>
  12. </div>
  13. </div>
  14. </template>
  15. <script>
  16. import { ref } from 'vue-demi';
  17. import iconList from '../../../iconfont/iconfont.json';
  18. export default {
  19. setup() {
  20. const keywords = ref('')
  21. const iconData = ref(iconList.glyphs)
  22. const search = (event) => {
  23. iconData.value = []
  24. iconList.glyphs.filter(item => {
  25. if(item.name.indexOf(event) != -1) {
  26. iconData.value.push(item)
  27. }
  28. })
  29. }
  30. return {
  31. keywords,
  32. iconData,
  33. search
  34. }
  35. }
  36. }
  37. </script>
  38. <style lang="scss" scoped>
  39. .icon-list{
  40. li{
  41. list-style: none;
  42. width: 16.66%;
  43. height: 120px;
  44. float: left;
  45. padding: 1vw;
  46. border-radius: 4px;
  47. box-sizing: border-box;
  48. text-align: center;
  49. font-size: 13px;
  50. transition: all .15s ease;
  51. cursor: pointer;
  52. i{
  53. font-size: 36px;
  54. color: #555;
  55. display: block;
  56. margin-top: 1vh;
  57. }
  58. span{
  59. display: inline-block;
  60. color: #555;
  61. margin-top: 1vh;
  62. margin-bottom: 1vh;
  63. }
  64. &:hover{
  65. i,span{
  66. color:#409eff;
  67. }
  68. }
  69. }
  70. }
  71. </style>