methods:{ async handleHashChange(e) { const path = new URL(e.newURL).hash.replace('#', ''); }, }, created() { window.addEventListener("hashchange", this.handleHashChange); }, beforeUnmount() { window.removeEventListener("hashchange", this.handleHashChange); } 扩展阅读 hashchange 事件