Vue3 Vuerouter4 addRoute issue #9518
-
Hello! My app uses routes from a database. In the When building for production an error message about top level await arrives, which is documented; I don't build for esnext. How can this be fixed? I have installed all latest packages:
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 13 replies
-
Correct. If you load such a route from the address bar, the route config hasn't been loaded upfront, so the router doesn't recognize the route you typed in the address bar. This is logical and unavoidable.
Load all routes upfront, like you wanted to from the beginning. If you can't use top-level await, use a bootstrap function or a normal promise instead. |
Beta Was this translation helpful? Give feedback.
Thanks a lot for your help and patience @LinusBorg.
I have used you second proposed solution and all works superb now!
Just a small reminder, the .map misses one ')'.
And very clean and mean :)
Have a nice evening!