JeepayTableColumns.vue 1.2 KB
Newer Older
D
dingzhiwei 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
<!--
  Jeepay 通用列,添加更多菜单项

  @author terrfly
  @site https://www.jeepay.vip
  @date 2021/5/8 07:18
-->
<script>
export default {
  name: 'JeepayTableColumns', // 定义组件名称
  render (createElement, context) {
    const slots = []
    this.$slots.default.map(item => {
      if (item.tag) {
        slots.push(item)
      }
      return false
    })
    if (slots.length <= 3) { // 小于等于三个直接渲染
      return createElement(
        'div',
        { style: 'display:flex; justify-content: space-evenly;' },
        slots // 子节点数组
      )
    } else {
      const firstEL = [slots[0], slots[1]]
      const menuEL = []
      for (let i = 2; i < slots.length; i++) {
        menuEL.push(<a-menu-item>{slots[i]}</a-menu-item>)
      }
      return <div style="display:flex; justify-content: space-evenly;"> {firstEL}
                  <a-dropdown>
qq_40137331's avatar
qq_40137331 已提交
33
                      <a-button style="line-height:32px" type="link" class="ant-dropdown-link">更多<a-icon type="down" /></a-button>
D
dingzhiwei 已提交
34 35 36 37 38 39 40 41 42
                      <a-menu slot="overlay">
                        {menuEL}
                      </a-menu>
                  </a-dropdown>
             </div>
    }
  }
}
</script>