s-space

123 阅读1分钟

处理当使用a-space里面的元素业务控制或者权限控制 隐藏时

a-space 错误的占了一个位置

<script>
// a-space 处理无权限的按钮占了位置
export default {
  name: 'SSpace',

  render () {
    const defaultSlot = this.$slots.default || []
    const list = []

    defaultSlot.forEach((item, index) => {
      // 没有权限
      const action = item.data && item.data.directives && item.data.directives.find(item1 => item1.name === 'action')
      if (action && !this.$route.meta.action.some(x => x === action.arg)) {
        return
      }

      // v-if 走这
      if (item.tag) {
        list.push(item)
      }
    })

    return (
      <a-space>
        {list}
      </a-space>
    )
  }
}
</script>