跳到主要内容

history

  • remix-run/history
    • 实现 router 的基础
    • 对应 window.history
  • api-reference
    • createPath,parsePath - url <-> location
    • createBrowserHistory, createHashHistory, createMemoryHistory
      • 三种不同的状态管理方式
    • history
      • createHref - browser 会考虑 <base/>
      • back,go
      • forward - go(1)
      • location - 当前 location
      • listen(({ action, location })=>{})
      • push, replace
      • block
    • location - pathname,search,hash,state,key
      • key - 唯一标识符,自动生成
  • 配合 URLPattern 可实现简单的路由功能
    • Chrome 95+