Skip to content

Vue Fragments ( React Fragments ) #7606

Closed
@ralphchristianeclipse

Description

@ralphchristianeclipse

What problem does this feature solve?

This solve the issue where multiple root components is not allowed like for instance

i'm trying to do this with slots using my own component for page loading and checking if its on loading and not loading state and checking if its valid to render the main component

<template lang="pug">
  v-progress-linear.ma-0(v-if="loading" color="secondary")
  div(v-else-if="loaded")
    slot
  v-container(fluid fill-height v-else)
    v-layout(justify-center align-center)
      slot(name="no-result")
        h1.text-xs-center No Result
</template>

<script>
export default {
  name: "Page",
  props: {
    loading: {
      type: Number,
      default: 0
    },
    valid: {
      type: Boolean
    }
  },
  computed: {
    loaded() {
      return this.valid && !this.loading;
    }
  }
};
</script>

So in this part of the template makes another div to just prevent the multiple root issue

  div(v-else-if="loaded")
    slot

so doing it like this would help

slot(fragment) Fall back content

I know this thing can be done somehow on render functions

but its not vueish anymore :)

What does the proposed API look like?

so in slots

we can do

<slot fragment></slot>

and in template syntax

<template fragment> </template>

Got the idea here https://reactjs.org/docs/fragments.html

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions