亚洲激情专区-91九色丨porny丨老师-久久久久久久女国产乱让韩-国产精品午夜小视频观看

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

Vue?Element-ui如何實現樹形控件節點添加圖標

發布時間:2021-11-23 17:37:09 來源:億速云 閱讀:481 作者:iii 欄目:開發技術

本篇內容主要講解“Vue Element-ui如何實現樹形控件節點添加圖標”,感興趣的朋友不妨來看看。本文介紹的方法操作簡單快捷,實用性強。下面就讓小編來帶大家學習“Vue Element-ui如何實現樹形控件節點添加圖標”吧!

1.效果圖

Vue?Element-ui如何實現樹形控件節點添加圖標

2.樹形表格綁定數據加標簽

想要在樹形控件的樹節點加上圖片或者element-ui的圖標,可以在樹形表格綁定數據中加上標簽icon

   children: [
       {
           icon:'el-icon-top-right',
           label: ['beam名稱',''],
           children: [
               {
                   label:['name','RS49'],
               },
               {
                   icon:'src/assets/images/Organization.png',
                   label:['group('+'3'+')','']
                   children:[
                   {
                   label:['10600361','10950','11200','0']
                    }
   					]
				}
           ]
		}
    ],

在樹形控件自定義函數中

直接讓class等于element-ui的icon標簽

img標簽需要加上自己圖片的地址

renderContent(h,{node,data,store}){
        // div代表樹形控件的一行,div中包含三個span標簽
        // 判斷節點的label數組數量,通過三目運算來選擇class
        // 設置class來控制樹形控件進行對齊
      return h('div',[
          // 在樹形控件自定義函數中增加icon和圖片的標簽
          // img標簽需要加上自己圖片的地址
           h('span',{class:'top-right'}),
          h('img',{src:data.icon}),
          h('span', {class:node.label.length === 2 ? 'nodeStyle':'groupStyle'},node.label[0]),
          h('span', {class:'groupStyle'},node.label[1]),
          h('span',{class:node.label.length === 2 ? 'nodeStyle':'groupStyle'},node.label.length === 2 ? 				'':node.label[2])
          ]);
    },

3.所有代碼

<template>
    <div class="mytree">
          <el-tree
              :data="tree_data"
              :props="defaultProps"
              @node-click="handleNodeClick"
              indent="0"
              :render-content="renderContent"
          ></el-tree>
        </div>
</template>

<script lang="ts">
import { defineComponent, ref  } from 'vue'
export default defineComponent({
    components: {},
    data() {
        return {
              tree_data: [
        		{
          // type:1,
         		 label: 'notice-id1',
                  children: [
                        {

                          label: ['衛星名稱代號','ZOHREH-2'],
                        },
                        {

                          label: ['組織機構','IRN'],
                        },
                        {
                          label: ['頻率范圍','10950-1450'],
                        },
                        {
                          icon:'el-icon-top-right',
                          label: ['beam名稱',''],
                          children: [
                              {
                                  label:['name','RS49'],
                              },
                             {
                                  label:['freq_min','10950'],
                              },
                             {
                                  label:['freq_max','14500'],
                              },
                              {
                                  icon:'src/assets/images/Organization.png',
                                  label:['group('+'3'+')','']
                                  children:[
                                     {
                                        label:['10600361','10950','11200','0']
                                     },
                                    {
                                        label:['10600361','10950','11200','0']
                                     },
                                    {
                                        label:['10600361','10950','11200','0']
                                     }
                                  ]
                              }
                      ]
                    },
                  ],
                },
              ],
            defaultProps: {
            children: 'children',
            label: 'label',
          },
        }
    },
    method:{
    // 自定義樹形控件函數 node代表每個節點
    renderContent(h,{node,data,store}){
        // div代表樹形控件的一行,div中包含三個span標簽
        // 判斷節點的label數組數量,通過三目運算來選擇class
        // 設置class來控制樹形控件進行對齊
      return h('div',[
          // 在樹形控件自定義函數中增加icon和圖片的標簽
           h('span',{class:[data.icon,data.icon==='el-icon-top-right'? 'top-right':'bottom-left']}),
          h('img',{src:data.icon === 'src/assets/images/Organization.png' ? data.icon:''}),
          h('span', {class:node.label.length === 2 ? 'nodeStyle':'groupStyle'},node.label[0]),
          h('span', {class:'groupStyle'},node.label[1]),
          h('span',{class:node.label.length === 2 ? 'nodeStyle':'groupStyle'},node.label.length === 2 ? 				'':node.label[2])
          ]);
    },
    }
    
})
</script>

<style lang="scss" scoped>
    
.nodeStyle{
  width:110px;
  display:inline-block;
  text-align:left;
}
.groupStyle{
  width:150px;
  display:inline-block;
  text-align:left;
}
    
</style>

到此,相信大家對“Vue Element-ui如何實現樹形控件節點添加圖標”有了更深的了解,不妨來實際操作一番吧!這里是億速云網站,更多相關內容可以進入相關頻道進行查詢,關注我們,繼續學習!

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

萍乡市| 大荔县| 新昌县| 南平市| 湖北省| 庆安县| 子长县| 南丰县| 时尚| 乐陵市| 于田县| 甘泉县| 梅河口市| 江华| 临猗县| 寿光市| 葵青区| 双城市| 荥阳市| 济源市| 莱芜市| 新安县| 石狮市| 鸡西市| 准格尔旗| 新巴尔虎右旗| 军事| 阿拉善左旗| 杭锦后旗| 黑河市| 周至县| 建始县| 邢台县| 曲水县| 阜宁县| 阳泉市| 钦州市| 鸡西市| 邵阳县| 农安县| 遂昌县|