1. 获取html文件#后面的部分:
    window.location.hash
  2. 添加onhashchange事件,监听路由变化:
    window.onhashchange = function(){
    }
  3. 完整代码:
    home
    index
    other
    
  4. 效果:
    react-router实现原理_第1张图片
    react-router实现原理_第2张图片
    react-router实现原理_第3张图片
    react-router实现原理_第4张图片