Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use slots on router-view to display an initial placeholder instead of an empty node #80

Closed
wants to merge 7 commits into from

Conversation

briwa
Copy link
Contributor

@briwa briwa commented Aug 20, 2019

TL;DR: There should be a way to render something on the browser, instead of an empty node, when vue-router has just been initialized.

Rendered

@briwa briwa changed the title feat: initial placeholder for vue router Vue router - initial placeholder to render instead of an empty node Aug 20, 2019
@posva posva changed the title Vue router - initial placeholder to render instead of an empty node Use slots on router-view to display an initial placeholder instead of an empty node Aug 20, 2019
@posva posva added the router label Aug 20, 2019
@michaeldrotar
Copy link

Sounds like a great idea. An issue I've faced is that you're still waiting for the app to load before it can do anything. What I've done instead is add the minimum css and html by hand to the index page for showing a splash screen or loading indicator and then once the initial route is rendered I'll hide them.

When using a loading indicator, it's generally also a component, but since I can't wait for the framework and my app to load, I have to copy/paste the necessary code from the component to the index page to get the fastest time to render so possibly a plugin would be really handy that could do this instead so that imports and sass and such things could still be used.

@briwa
Copy link
Contributor Author

briwa commented Oct 25, 2019

Hello @posva, sorry for bumping this 3 months-old PR. Was wondering if you're ok with this RFC? So that I can proceed with vuejs/vue-router#2799. Thank you.

@posva
Copy link
Member

posva commented Oct 25, 2019

@briwa Sorry, but we are not sure this is the direction we want to go yet. So please, don't add more commits to the PR. We will come back at you when we can

@posva
Copy link
Member

posva commented Apr 1, 2020

If you check $route.matched.length to know if there is a match, you could initially display something while the router has nothing to display:

<router-view v-if="$route.matched.length"/>
<loading-view v-else/>

Or by comparing to the initial location (vuejs/vue-router#2718)

<router-view v-if="$route !== START"/>
<loading-view v-else/>

Apart from a builtin way to handle this, why would using the default slot better? Having it as a default makes it impossible to escape, which could be problematic for Declarative Routing (adding routes as we enter a View)

@posva
Copy link
Member

posva commented Jul 29, 2020

Thanks a lot for the RFC. I'm closing this for the reasons mentioned above and because this can be achieved with #153 which has a broader intention.

So far this has only been implemented on router v4 but It will likely be ported back to router v3 as well

@posva posva closed this Jul 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants