vue自定义实现icon选择器

<template>
  <el-popover
      placement="bottom"
      width="300"
      trigger="click"
      :class="'select-icon'"
      @show="popoverShow"
  >
    <span slot="reference">
      <el-input suffix-icon='data-icon' v-model='value' placeholder='请选择'>
       <template slot="prepend"><i :class="value"/></template>
      </el-input>
    </span>
    <div class="iconList">
      <el-tabs v-model="activeName">
        <el-tab-pane
            v-for="(item, index) in list"
            :key="item.label"
            :name="item.label"
            :label="item.label"
        >
          <el-scrollbar wrap-class="scrollbar-wrapper">
            <span class="icon" v-for="item in item.list" :key="item">
              <i :key="item" :class="[ item]" @click="setIcon(item)"></i>
            </span>
          </el-scrollbar>

        </el-tab-pane>
      </el-tabs>
    </div>
  </el-popover>
</template>

<script>
export default {
  name: "selectIcon",
  model:{
    prop:'value',
    event:'input'
  },
  props:{
    value:{
      type:String,
      default:''
    }
  },
  data() {
    return {
      activeName:'线框',
      list:[
        {
          label:'线框',
          list:['el-icon-eleme', 'el-icon-delete', 'el-icon-setting', 'el-icon-user','el-icon-phone-outline','el-icon-more-outline','el-icon-star-off','el-icon-goods','el-icon-warning-outline','el-icon-zoom-in', 'el-icon-zoom-out', 'el-icon-remove-outline', 'el-icon-circle-plus-outline', 'el-icon-circle-check', 'el-icon-circle-close', 'el-icon-help', 'el-icon-minus', 'el-icon-plus', 'el-icon-check', 'el-icon-close','el-icon-picture-outline', 'el-icon-picture-outline-round','el-icon-upload2','el-icon-download','el-icon-camera','el-icon-video-camera','el-icon-bell','el-icon-bottom-left', 'el-icon-bottom-right', 'el-icon-back', 'el-icon-right', 'el-icon-bottom', 'el-icon-top', 'el-icon-top-left', 'el-icon-top-right', 'el-icon-arrow-left', 'el-icon-arrow-right', 'el-icon-arrow-down', 'el-icon-arrow-up', 'el-icon-d-arrow-left', 'el-icon-d-arrow-right', 'el-icon-video-pause', 'el-icon-video-play', 'el-icon-refresh', 'el-icon-refresh-right', 'el-icon-refresh-left', 'el-icon-finished', 'el-icon-sort', 'el-icon-sort-up', 'el-icon-sort-down', 'el-icon-rank', 'el-icon-loading', 'el-icon-view', 'el-icon-c-scale-to-original', 'el-icon-date', 'el-icon-edit', 'el-icon-edit-outline', 'el-icon-folder', 'el-icon-folder-opened', 'el-icon-folder-add', 'el-icon-folder-remove', 'el-icon-folder-delete', 'el-icon-folder-checked', 'el-icon-tickets', 'el-icon-document-remove', 'el-icon-document-delete', 'el-icon-document-copy', 'el-icon-document-checked', 'el-icon-document', 'el-icon-document-add', 'el-icon-printer', 'el-icon-paperclip', 'el-icon-takeaway-box', 'el-icon-search', 'el-icon-monitor', 'el-icon-attract', 'el-icon-mobile', 'el-icon-scissors', 'el-icon-umbrella',
'el-icon-headset',
'el-icon-brush',
'el-icon-mouse',
'el-icon-coordinate',
'el-icon-magic-stick',
'el-icon-reading',
'el-icon-data-line',
'el-icon-data-board',
'el-icon-pie-chart',
'el-icon-data-analysis',
'el-icon-collection-tag',
'el-icon-film',
'el-icon-suitcase',
'el-icon-suitcase-1',
'el-icon-receiving',
'el-icon-collection',
'el-icon-files',
'el-icon-notebook-1',
'el-icon-notebook-2',
'el-icon-toilet-paper',
'el-icon-office-building',
'el-icon-school',
'el-icon-table-lamp',
'el-icon-house',
'el-icon-no-smoking',
'el-icon-smoking',
'el-icon-shopping-cart-full',
'el-icon-shopping-cart-1',
'el-icon-shopping-cart-2',
'el-icon-shopping-bag-1',
'el-icon-shopping-bag-2',
'el-icon-sold-out',
'el-icon-sell',
'el-icon-present',
'el-icon-box',
'el-icon-bank-card',
'el-icon-money',
'el-icon-coin',
'el-icon-wallet',
'el-icon-discount',
'el-icon-price-tag',
'el-icon-news',
'el-icon-guide',
'el-icon-male',
'el-icon-female',
'el-icon-thumb',
'el-icon-cpu',
'el-icon-link',
'el-icon-connection',
'el-icon-open',
'el-icon-turn-off',
'el-icon-set-up',
'el-icon-chat-round',
'el-icon-chat-line-round',
'el-icon-chat-square',
'el-icon-chat-dot-round',
'el-icon-chat-dot-square',
'el-icon-chat-line-square',
'el-icon-message',
'el-icon-postcard',
'el-icon-position',
'el-icon-turn-off-microphone',
'el-icon-microphone',
'el-icon-close-notification',
'el-icon-bangzhu',
'el-icon-time',
'el-icon-odometer',
'el-icon-crop',
'el-icon-aim',
'el-icon-switch-button',
'el-icon-full-screen',
'el-icon-copy-document',
'el-icon-mic',
'el-icon-stopwatch',
'el-icon-medal-1',
'el-icon-medal',
'el-icon-trophy',
'el-icon-trophy-1',
'el-icon-first-aid-kit',
'el-icon-discover',
'el-icon-place',
'el-icon-location',
'el-icon-location-outline',
'el-icon-location-information',
'el-icon-add-location',
'el-icon-delete-location',
'el-icon-map-location',
'el-icon-alarm-clock',
'el-icon-timer',
'el-icon-watch-1',
'el-icon-watch',
'el-icon-lock',
'el-icon-unlock',
'el-icon-key',
'el-icon-service',
'el-icon-mobile-phone',
'el-icon-bicycle',
'el-icon-truck',
'el-icon-ship',
'el-icon-basketball',
'el-icon-football',
'el-icon-soccer',
'el-icon-baseball',
'el-icon-wind-power',
'el-icon-light-rain',
'el-icon-lightning',
'el-icon-heavy-rain',
'el-icon-sunrise',
'el-icon-sunrise-1',
'el-icon-sunset',
'el-icon-sunny',
'el-icon-cloudy',
'el-icon-partly-cloudy',
'el-icon-cloudy-and-sunny',
'el-icon-moon',
'el-icon-moon-night',
'el-icon-dish',
'el-icon-dish-1',
'el-icon-food',
'el-icon-chicken',
'el-icon-fork-spoon',
'el-icon-knife-fork',
'el-icon-burger',
'el-icon-tableware',
'el-icon-sugar',
'el-icon-dessert',
'el-icon-ice-cream',
'el-icon-hot-water',
'el-icon-water-cup',
'el-icon-coffee-cup',
'el-icon-cold-drink',
'el-icon-goblet',
'el-icon-goblet-full',
'el-icon-goblet-square',
'el-icon-goblet-square-full',
'el-icon-refrigerator',
'el-icon-grape',
'el-icon-watermelon',
'el-icon-cherry',
'el-icon-apple',
'el-icon-pear',
'el-icon-orange',
'el-icon-coffee',
'el-icon-ice-tea',
'el-icon-ice-drink',
'el-icon-milk-tea',
'el-icon-potato-strips',
'el-icon-lollipop',
'el-icon-ice-cream-square',
'el-icon-ice-cream-round']
        },
        {
          label:'实心',
          list:['el-icon-platform-eleme', 'el-icon-delete-solid', 'el-icon-s-tools', 'el-icon-user-solid','el-icon-phone','el-icon-more','el-icon-star-on','el-icon-s-goods','el-icon-warning','el-icon-question', 'el-icon-info', 'el-icon-remove','el-icon-circle-plus','el-icon-success','el-icon-error', 'el-icon-s-help','el-icon-picture','el-icon-upload','el-icon-camera-solid','el-icon-video-camera-solid','el-icon-message-solid','el-icon-s-cooperation', 'el-icon-s-order', 'el-icon-s-platform', 'el-icon-s-fold', 'el-icon-s-unfold', 'el-icon-s-operation', 'el-icon-s-promotion', 'el-icon-s-home', 'el-icon-s-release', 'el-icon-s-ticket', 'el-icon-s-management', 'el-icon-s-open', 'el-icon-s-shop', 'el-icon-s-marketing', 'el-icon-s-flag', 'el-icon-s-comment', 'el-icon-s-finance', 'el-icon-s-claim', 'el-icon-s-custom', 'el-icon-s-opportunity', 'el-icon-s-data', 'el-icon-s-check', 'el-icon-s-grid', 'el-icon-menu', 'el-icon-share', 'el-icon-d-caret', 'el-icon-caret-left', 'el-icon-caret-right', 'el-icon-caret-bottom', 'el-icon-caret-top']
        }
      ]
    }
  },
  methods:{
    setIcon(row){
        this.$emit('input', row)
    },
    popoverShow(obj){

    }
  }
}
</script>

<style scoped lang="scss">
.iconList{
  .el-tab-pane{
    .el-scrollbar{
      height: 200px;
      overflow-x: hidden !important;
      .icon{
        display: inline-block;
        width: calc((100% - 60px) / 6);
        height: 40px;
        border: 1px solid #ededed;
        text-align: center;
        box-sizing: border-box;
        line-height: 38px;
        margin-right: 10px;
        border-radius: 3px;
        margin-top: 10px;
        cursor: pointer;
        &:nth-child(-n+6){
          margin-top: 0;
        }
        i{
          font-size: 16px;
          color: #303133;
          transition: all 100ms;
        }
        &:hover{
          box-shadow: 0 4px 12px 0 rgba(0,0,0,.15);
          i{
            transform: scale(1.5);
          }
        }
      }
    }
  }

}
</style>
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 205,033评论 6 478
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 87,725评论 2 381
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 151,473评论 0 338
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 54,846评论 1 277
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 63,848评论 5 368
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 48,691评论 1 282
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 38,053评论 3 399
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,700评论 0 258
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 42,856评论 1 300
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,676评论 2 323
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 37,787评论 1 333
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,430评论 4 321
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 39,034评论 3 307
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 29,990评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,218评论 1 260
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 45,174评论 2 352
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 42,526评论 2 343