-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Closed as not planned
Closed as not planned
Copy link
Description
Reproduction
https://codesandbox.io/s/modern-resonance-fmxl4t
Steps to reproduce the bug
import { createApp } from "vue";
import App from "./App.vue";
import { router } from "./router";
const app = createApp(App).use(router); // Asynchronously bounce back to the URL when router instance created .
window.history.replaceState({}, "", "/foo"); // Doesn't work, router doesn't take it into account.
app.mount("#app");
window.history.replaceState({}, "", "/bar"); // Doesn't work, router doesn't take it into account.Expected behavior
....
const app = createApp(App).use(router);
window.history.replaceState({}, "", "/foo"); // Finally will navigate to /foo
app.mount("#app");and
....
const app = createApp(App).use(router);
app.mount("#app");
window.history.replaceState({}, "", "/bar"); // Finally will navigate to /barActual behavior
...
const app = createApp(App).use(router); // navigate to the URL when router instance created asynchronously.
window.history.replaceState({}, "", "/foo"); // Doesn't work.
app.mount("#app");
window.history.replaceState({}, "", "/bar"); // Doesn't work.Additional information
The behavior of installing router to instance of Vue is not intuitive.
After building the router instance by calling the createRouter, the URL will be saved into routerHistory, and it will be pushed when installing to instance of Vue asynchronously, even if the routerHistory is stale. (E.g the location is modified when install)
Somehow I think we should use the current browser location when installing the router instance, and this behavior is more intuitive.
Metadata
Metadata
Assignees
Labels
No labels