Kitware / trame-router

trame-router brings Vue Router capabilities into trame widgets and ui
MIT License
1 stars 1 forks source link

[Vue3] RouterView doesn't populate correctly on page loads #1

Closed andrepearce closed 8 months ago

andrepearce commented 8 months ago

Problem

When using Vue3 and the example provided at examples/vue3/basic.py, the RouterView does not display the route that should be active on the page load. Additionally, you can see in the browser console a warning that says:

[Vue Router warn]: No match found for location with path "/"

It is worth noting that after page load if you click the list items in the nav draw, the routes seem to display correctly. The issue is only on page load/reload. This does not appear to be an issue when using Vue2.

Steps to Reproduce

  1. pip install trame trame-vuetify trame-router
  2. cd examples/vue3
  3. python basic.py --port 8988
  4. Open a browser at http://localhost:8988
  5. Observe the fact that no content is rendered in the RouterView
  6. Open the browser console and observe the Vue Router warning
  7. Click on one of the nav buttons and observe the router view correctly populate itself without creating any warnings in the browser console
  8. Reload the page (keeping the route in the URL path), observe the content failing to load in the RouterView and another warning in the browser console

Environment Setup

I am using the following package versions:

trame==3.5.2
trame-client==2.15.0
trame-router==2.1.0
trame-server==2.15.0
trame-vuetify==2.4.2

Possible Solution

Not sure yet... however I think it could be related to the fact the router object is initialized with no routes on the following line: https://github.com/Kitware/trame-router/blob/69fe15df8cedbed1f585b65d5cc2889af160e31b/vue3/src/use.js#L7

jourdain commented 8 months ago

Thanks for pointing out the issue!