vue-router模式 history 和 hash

42 阅读1分钟

hash

简单流程​​:修改 location.hash→ 触发 hashchange事件 → Vue Router 匹配路由 → 更新视图

history

简单流程​​:调用 history.pushState()→ URL 改变,页面不刷新 → Vue Router 内部匹配路由 → 更新视图;点击前进/后退 → 触发 popstate事件 → Vue Router 匹配新 URL → 更新视图。