<!doctype html>
<html lang="en">
<body>
    <a href="#/home">首页</a>
    <a href="#/course">课程</a>

    <div ></div>

    <script>
        window.onhashchange = function(){
            console.log(location.hash);
            switch (location.hash) {
                case '#/home':
                    document.getElementById('app').innerHTML = '<h2>我是首页</h2>';
                    break;
                case '#/course':
                    document.getElementById('app').innerHTML = '<h2>我是课程</h2>';
                    break;
                default:
                    // statements_def
                    break;
            }
        }

    </script>
</body>
</html>

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-04
  • 2021-07-24
  • 2021-06-13
  • 2021-07-05
  • 2022-12-23
猜你喜欢
  • 2021-08-06
  • 2021-06-19
  • 2021-08-26
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案