Closed Bornegrim closed 3 years ago
This sounds similar to https://github.com/single-spa/create-single-spa/issues/311. In that issue, I showed a workaround that involves modifying vue-router. I plan on submitting a pull request to vue-router to fix issues related to cancellation.
I'll take a look at your demonstration repo to see if it's the same issue.
I confirmed that the same workaround I described in #311 works for this case, too. I'll have to think more carefully about what the best approach is to fix, this, though. Not 100% sure if it's vue-router's fault or single-spa's fault.
I looked into this further and found a way to fix this without any need to modify vue-router. The bug only occurs when single-spa's urlRerouteOnly
option is set to false
. In single-spa@5, false is the default, but in single-spa@6 we've changed the default to true.
I've created https://github.com/Bornegrim/vue3-single-spa/pull/1 which I verified works in your demonstration repo.
To fix, you must ensure that single-spa's start()
function is called with urlRerouteOnly
set to true
. There are three ways to do that.
start()
call to be start({urlRerouteOnly: true})
Relevant links:
This is documented at https://github.com/single-spa/single-spa.js.org/pull/477
i try modify to be start({urlRerouteOnly: true}),router-link is work, but router-view still not work,Any idea why?
Thanks @joeldenning I spent a day on this issue. This finally helped getting through it.
Here is an example that reproduces the issue: GitHub repo.
The repo is created with Vue-CLI (vue create) and single-spa is added with (vue add single-spa).
To reproduce the issue:
npm run serve:standalone
Our team has been using single-spa in our application and recently started updating spas to Vue 3. During this upgrade, we have been facing some issues regarding routing. When you route using router-link or router.push the router navigates multiple times and throws this error:
The error is printed by adding this code to the router config: Vue navigation failure docs
The router navigates properly to the destination but when you use the browser back button (or router.go(-1)) the navigation stays on the same page without any errors. It changes the URL to where we want to go but it's not navigating back. It is possible to navigate backward by pressing the browser back button multiple times. If you navigate by typing the URL manually it works as expected.
If you create the app the same way (with Vue-CLI + vue add single-spa) but choose Vue 2 instead of Vue 3 it works as expected.
How do you integrate Vue 3 + Vue router with single-spa?