Ver Fonte

fix back button for SPA example (fixes #3910)

Falko Schindler há 6 meses atrás
pai
commit
3b9293db14
1 ficheiros alterados com 2 adições e 3 exclusões
  1. 2 3
      examples/single_page_app/router_frame.js

+ 2 - 3
examples/single_page_app/router_frame.js

@@ -1,10 +1,9 @@
 export default {
   template: "<div><slot></slot></div>",
   mounted() {
+    const initial_path = window.location.pathname;
     window.addEventListener("popstate", (event) => {
-      if (event.state?.page) {
-        this.$emit("open", event.state.page);
-      }
+      this.$emit("open", event.state?.page || initial_path);
     });
     const connectInterval = setInterval(async () => {
       if (window.socket.id === undefined) return;